Commit 26fd9118 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Remove deprecated pqCurrentTimeToolbar.

pqCurrentTimeToolbar is now replaced by pqAnimationTimeWidget.

Change-Id: Ifd433d73883a7e6909ad707d10c379d3cb24feed
parent ac872a8e
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>344</width>
<width>346</width>
<height>27</height>
</rect>
</property>
......@@ -19,7 +19,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0,1">
<property name="spacing">
<number>2</number>
</property>
......@@ -45,12 +45,6 @@
</item>
<item>
<widget class="pqLineEdit" name="timeValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>0</string>
</property>
......@@ -86,6 +80,22 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
......
......@@ -31,17 +31,32 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqAnimationTimeToolbar.h"
#include "pqPVApplicationCore.h"
#include "pqAnimationManager.h"
#include "pqAnimationScene.h"
#include "pqAnimationTimeWidget.h"
#include "pqPVApplicationCore.h"
//-----------------------------------------------------------------------------
void pqAnimationTimeToolbar::constructor()
{
this->setWindowTitle("Current Time Controls");
QObject::connect(pqPVApplicationCore::instance()->animationManager(),
this->AnimationTimeWidget = new pqAnimationTimeWidget(this);
this->AnimationTimeWidget->setPlayModeReadOnly(true);
this->addWidget(this->AnimationTimeWidget);
this->connect(pqPVApplicationCore::instance()->animationManager(),
SIGNAL(activeSceneChanged(pqAnimationScene*)),
this, SLOT(setAnimationScene(pqAnimationScene*)));
SLOT(setAnimationScene(pqAnimationScene*)));
}
//-----------------------------------------------------------------------------
void pqAnimationTimeToolbar::setAnimationScene(pqAnimationScene* scene)
{
this->AnimationTimeWidget->setAnimationScene(
scene? scene->getProxy() : NULL);
}
//-----------------------------------------------------------------------------
pqAnimationTimeWidget* pqAnimationTimeToolbar::animationTimeWidget() const
{
return this->AnimationTimeWidget;
}
......@@ -7,8 +7,8 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
......@@ -29,18 +29,24 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqAnimationTimeToolbar_h
#ifndef __pqAnimationTimeToolbar_h
#define __pqAnimationTimeToolbar_h
#include "pqCurrentTimeToolbar.h"
#include "pqApplicationComponentsModule.h"
#include <QToolBar>
#include <QPointer>
class pqAnimationTimeWidget;
class pqAnimationScene;
/// pqAnimationTimeToolbar is subclass of pqCurrentTimeToolbar that connects to
/// the pqPVApplicationCore::animationManager() to keep track of the active scene.
class PQAPPLICATIONCOMPONENTS_EXPORT pqAnimationTimeToolbar : public pqCurrentTimeToolbar
/// pqAnimationTimeToolbar is a QToolBar containing a pqAnimationTimeWidget.
/// pqAnimationTimeToolbar also ensures that the pqAnimationTimeWidget is
/// tracking the animation scene on the active session.
class PQAPPLICATIONCOMPONENTS_EXPORT pqAnimationTimeToolbar : public QToolBar
{
Q_OBJECT
typedef pqCurrentTimeToolbar Superclass;
typedef QToolBar Superclass;
public:
pqAnimationTimeToolbar(const QString &_title, QWidget *_parent = 0)
: Superclass(_title, _parent)
......@@ -53,10 +59,15 @@ public:
this->constructor();
}
/// Provides access to the pqAnimationTimeWidget used.
pqAnimationTimeWidget* animationTimeWidget() const;
private slots:
void setAnimationScene(pqAnimationScene* scene);
private:
Q_DISABLE_COPY(pqAnimationTimeToolbar)
void constructor();
QPointer<pqAnimationTimeWidget> AnimationTimeWidget;
};
#endif
......
......@@ -145,6 +145,9 @@ void pqAnimationTimeWidget::setAnimationScene(vtkSMProxy* animationScene)
internals.Links.addPropertyLink<pqAnimationTimeWidgetLinks>(
this, "timeStepCount", SIGNAL(dummySignal()),
timeKeeper, timeKeeper->GetProperty("TimestepValues"));
internals.Links.addPropertyLink(
this, "timeLabel", SIGNAL(dummySignal()),
timeKeeper, timeKeeper->GetProperty("TimeLabel"));
}
//-----------------------------------------------------------------------------
......@@ -249,6 +252,20 @@ void pqAnimationTimeWidget::timestepValueChanged()
emit this->timeValueChanged();
}
}
//-----------------------------------------------------------------------------
void pqAnimationTimeWidget::setTimeLabel(const QString& val)
{
Ui::AnimationTimeWidget &ui = this->Internals->Ui;
ui.timeLabel->setText(val + ":");
}
//-----------------------------------------------------------------------------
QString pqAnimationTimeWidget::timeLabel() const
{
Ui::AnimationTimeWidget &ui = this->Internals->Ui;
QString txt = ui.timeLabel->text();
return txt.left(txt.length()-1);
}
//-----------------------------------------------------------------------------
void pqAnimationTimeWidget::setPlayModeReadOnly(bool val)
......
......@@ -58,6 +58,7 @@ class PQAPPLICATIONCOMPONENTS_EXPORT pqAnimationTimeWidget : public QWidget
Q_PROPERTY(int timeStepCount READ timeStepCount WRITE setTimeStepCount)
Q_PROPERTY(QString playMode READ playMode WRITE setPlayMode)
Q_PROPERTY(bool playModeReadOnly READ playModeReadOnly WRITE setPlayModeReadOnly)
Q_PROPERTY(QString timeLabel READ timeLabel WRITE setTimeLabel)
typedef QWidget Superclass;
public:
......@@ -85,6 +86,9 @@ public:
void setPlayModeReadOnly(bool val);
bool playModeReadOnly() const;
/// Get/set the label text to use for the "time" parameter.
void setTimeLabel(const QString& val);
QString timeLabel() const;
signals:
void timeValueChanged();
void playModeChanged();
......
......@@ -102,8 +102,6 @@ set (Module_SRCS
pqContourWidget.h
pqCubeAxesEditorDialog.cxx
pqCubeAxesEditorDialog.h
pqCurrentTimeToolbar.cxx
pqCurrentTimeToolbar.h
pqCustomFilterDefinitionModel.cxx
pqCustomFilterDefinitionModel.h
pqCustomFilterDefinitionWizard.cxx
......@@ -396,7 +394,6 @@ set (Module_MOC_HDRS
pqComponentsTestUtility.h
pqContourWidget.h
pqCubeAxesEditorDialog.h
pqCurrentTimeToolbar.h
pqCustomFilterDefinitionWizard.h
pqCustomFilterManager.h
pqCustomFilterManagerModel.h
......
/*=========================================================================
Program: ParaView
Module: pqCurrentTimeToolbar.cxx
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#include "pqCurrentTimeToolbar.h"
// Server Manager Includes.
#include "vtkSMProxy.h"
#include "vtkSMProperty.h"
// Qt Includes.
#include <QAction>
#include <QLabel>
#include <QLineEdit>
// ParaView Includes.
#include "pqSpinBox.h"
#include "pqAnimationScene.h"
#include "pqTimeKeeper.h"
#include "pqServer.h"
#include "pqSMAdaptor.h"
//-----------------------------------------------------------------------------
pqCurrentTimeToolbar::pqCurrentTimeToolbar(
const QString &mytitle, QWidget *myparent): Superclass(mytitle, myparent)
{
this->constructor();
}
//-----------------------------------------------------------------------------
pqCurrentTimeToolbar::pqCurrentTimeToolbar(QWidget *myparent) :
Superclass(myparent)
{
this->constructor();
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::constructor()
{
QLabel* label = new QLabel(this);
label->setText("Time: ");
this->TimeLabel = label;
QLineEdit* timeedit = new QLineEdit(this);
timeedit->setSizePolicy(
QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
timeedit->setObjectName("CurrentTime");
timeedit->setValidator(new QDoubleValidator(this));
this->TimeLineEdit = timeedit;
QSpinBox* sbtimeedit = new pqSpinBox(this);
sbtimeedit->setObjectName("CurrentTimeIndex");
sbtimeedit->setMaximum(10000); // ensure that the widget is atleast 10000 wide.
this->TimeSpinBox = sbtimeedit;
//QObject::connect(
// this->TimeSpinBox, SIGNAL(valueChanged(int)),
// this, SLOT(currentTimeIndexChanged()));
QObject::connect(
this->TimeSpinBox, SIGNAL(editingFinished()),
this, SLOT(currentTimeIndexChanged()));
QObject::connect(
this->TimeLineEdit, SIGNAL(editingFinished()),
this, SLOT(currentTimeEdited()));
this->addWidget(label);
this->addWidget(timeedit);
this->addWidget(sbtimeedit);
QLabel* countLabel = new QLabel(this);
countLabel->setText(" of (TBD)");
this->CountLabelAction = this->addWidget(countLabel);
this->CountLabel = countLabel;
// need to use CountLabelAction to show/hide label.
this->CountLabelAction->setVisible(false);
this->ShowFrameCount = true;
}
//-----------------------------------------------------------------------------
pqCurrentTimeToolbar::~pqCurrentTimeToolbar()
{
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::setShowFrameCount(bool val)
{
this->ShowFrameCount = val;
if (this->TimeSpinBox->isEnabled() && val)
{
this->CountLabelAction->setVisible(true);
}
else
{
this->CountLabelAction->setVisible(false);
}
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::setAnimationScene(pqAnimationScene* scene)
{
if (this->Scene == scene)
{
return;
}
if (this->Scene)
{
QObject::disconnect(this->Scene, 0, this, 0);
QObject::disconnect(this, 0, this->Scene, 0);
}
this->Scene = scene;
if (this->Scene)
{
QObject::connect(this->Scene, SIGNAL(animationTime(double)),
this, SLOT(sceneTimeChanged(double)));
QObject::connect(this->Scene, SIGNAL(playModeChanged()),
this, SLOT(onPlayModeChanged()));
QObject::connect(this, SIGNAL(changeSceneTime(double)),
this->Scene, SLOT(setAnimationTime(double)));
QObject::connect(this->Scene, SIGNAL(timeStepsChanged()),
this, SLOT(onTimeStepsChanged()));
QObject::connect(this->Scene, SIGNAL(timeLabelChanged()),
this, SLOT(onTimeLabelChanged()));
this->sceneTimeChanged(this->Scene->getAnimationTime());
}
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::onTimeStepsChanged()
{
bool prev = this->TimeSpinBox->blockSignals(true);
pqTimeKeeper* timekeeper = this->Scene->getServer()->getTimeKeeper();
int time_steps = timekeeper->getNumberOfTimeStepValues();
if (time_steps > 0)
{
this->TimeSpinBox->setMaximum(time_steps -1);
this->CountLabel->setText(QString(" of %1").arg(time_steps));
}
else
{
this->TimeSpinBox->setMaximum(0);
this->CountLabel->setText("");
}
this->TimeSpinBox->blockSignals(prev);
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::onTimeLabelChanged()
{
pqTimeKeeper* timekeeper = this->Scene->getServer()->getTimeKeeper();
this->TimeLabel->setText(
pqSMAdaptor::getElementProperty(
timekeeper->getProxy()->GetProperty("TimeLabel")).toString());
this->TimeLabel->setText(this->TimeLabel->text() + ": ");
}
//-----------------------------------------------------------------------------
void pqCurrentTimeToolbar::onPlayModeChanged()
{
if (this->Scene)
{
this->sceneTimeChanged(this->Scene->getAnimationTime());
}
}
//-----------------------------------------------------------------------------
// When user edits the spin-box
void pqCurrentTimeToolbar::currentTimeIndexChanged()
{
if (this->Scene)
{
pqTimeKeeper* timekeeper = this->Scene->getServer()->getTimeKeeper();
emit this->changeSceneTime(
timekeeper->getTimeStepValue(this->TimeSpinBox->value()));
}
}
//-----------------------------------------------------------------------------
// When user edits the line-edit.
void pqCurrentTimeToolbar::currentTimeEdited()
{
emit this->changeSceneTime(this->TimeLineEdit->text().toDouble());
}
//-----------------------------------------------------------------------------
// update GUI based on time.
void pqCurrentTimeToolbar::sceneTimeChanged(double time)
{
if (!this->Scene)
{
return;
}
bool prev = this->blockSignals(true);
pqTimeKeeper* timekeeper = this->Scene->getServer()->getTimeKeeper();
vtkSMProxy* proxy = this->Scene->getProxy();
QString playmode = pqSMAdaptor::getEnumerationProperty(
proxy->GetProperty("PlayMode")).toString();
if (playmode == "Snap To TimeSteps")
{
int index = timekeeper->getTimeStepValueIndex(time);
this->TimeSpinBox->setValue(index);
this->TimeSpinBox->setEnabled(true);
if (this->ShowFrameCount)
{
this->CountLabelAction->setVisible(true);
}
this->TimeLineEdit->setEnabled(false);
}
else
{
this->TimeSpinBox->setEnabled(false);
this->CountLabelAction->setVisible(false);
this->TimeLineEdit->setEnabled(true);
}
this->TimeLineEdit->setText(QString::number(time));
this->blockSignals(prev);
}
/*=========================================================================
Program: ParaView
Module: pqCurrentTimeToolbar.h
Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef __pqCurrentTimeToolbar_h
#define __pqCurrentTimeToolbar_h
#include <QToolBar>
#include <QPointer>
#include "pqComponentsModule.h"
class QLineEdit;
class QSpinBox;
class QLabel;
class pqAnimationScene;
/// pqCurrentTimeToolbar is a toolbar that shows the current animation time.
/// It stays linked with the current animation scene's animation time. To use
/// this, simply create this toolbar and place it in the GUI as needed. Either
/// set the current animation scene directly or connect it to the
/// pqAnimationManager's scene-changed signal.
class PQCOMPONENTS_EXPORT pqCurrentTimeToolbar : public QToolBar
{
Q_OBJECT
typedef QToolBar Superclass;
Q_PROPERTY(bool showFrameCount READ showFrameCount WRITE setShowFrameCount);
public:
pqCurrentTimeToolbar(const QString &title, QWidget *parent = 0);
pqCurrentTimeToolbar(QWidget *parent = 0);
virtual ~pqCurrentTimeToolbar();
/// Returns the current animation scene to which this toolbar is linked.
pqAnimationScene* animationScene() const;
/// Returns whether frame count is shown in the toolbar, if applicable.
bool showFrameCount() const
{ return this->ShowFrameCount; }
public slots:
/// Set the animation scene.
void setAnimationScene(pqAnimationScene*);
/// Set whether frame count is shown in the toolbar, if applicable.
void setShowFrameCount(bool val);
protected slots:
/// Called when animation scene reports that it's time has changed.
void sceneTimeChanged(double);
/// When user edits the line-edit.
void currentTimeEdited();
/// When user edits the spin-box
void currentTimeIndexChanged();
void onPlayModeChanged();
/// Update range for the spin box.
void onTimeStepsChanged();
/// Update the label text
void onTimeLabelChanged();
signals:
/// emitted to request the scene to change it's animation time.
void changeSceneTime(double);
protected:
QLineEdit* TimeLineEdit;
QSpinBox* TimeSpinBox;
QLabel* TimeLabel;
QLabel* CountLabel;
QAction* CountLabelAction;
bool ShowFrameCount;
private:
pqCurrentTimeToolbar(const pqCurrentTimeToolbar&); // Not implemented.
void operator=(const pqCurrentTimeToolbar&); // Not implemented.
void constructor();
QPointer<pqAnimationScene> Scene;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment