COPASI API  4.16.103
CQBaseWidget.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #include <QtCore/QVariant>
7 #include <QtGui/QPushButton>
8 #include <QtGui/QLabel>
9 #include <QtGui/QSlider>
10 #include <QtGui/QLayout>
11 #include <QtGui/QToolTip>
12 #include <QtGui/QAction>
13 #include <QtGui/QMenuBar>
14 
15 //Added by qt3to4:
16 #include <iostream>
17 
18 #ifdef DEBUG_UI
19 #include <QtCore/QtDebug>
20 #endif
21 
22 #include "CQBaseWidget.h"
23 
24 /*
25  * Constructs a CQBaseWidget as a child of 'parent', with the
26  * name 'name' and widget flags set to 'f'.
27  *
28  */
29 CQBaseWidget::CQBaseWidget(QWidget* parent, const char* /* name */, Qt::WFlags fl)
30  : QWidget(parent, fl),
31  mSliderActive(false),
32  mScaleFactor(1000)
33 {
34  setupUi(this);
35 
37 
38  connect(mpSliderRow, SIGNAL(valueChanged(int)), this, SLOT(setSlider()));
39  connect(mpSliderColumn, SIGNAL(valueChanged(int)), this, SLOT(setSlider()));
40 }
41 
42 /*
43  * Destroys the object and frees any allocated resources
44  */
46 {}
47 
48 void CQBaseWidget::setSliderActive(const bool & active)
49 {
50  mSliderActive = active;
51 
52  if (mSliderActive)
53  {
54  mpLabelRow->show();
55  mpSliderRow->show();
56  mpLabelColumn->show();
57  mpSliderColumn->show();
58  }
59  else
60  {
61  mpLabelRow->hide();
62  mpSliderRow->hide();
63  mpLabelColumn->hide();
64  mpSliderColumn->hide();
65  }
66 }
67 
69 {
70  return mSliderActive;
71 }
72 
74 {
75  if (!mSliderActive) return;
76 
77  int row = mpSliderRow->value();
78  int col = mpSliderColumn->value();
79 
80 #ifdef DEBUG_UI
81  qDebug() << "A CQBaseWidget::setSlider -> col = " << col << " - row = " << row;
82 #endif
83 
84  sliderMoved(mpSliderColumn->value() / mScaleFactor, mpSliderRow->value() / mScaleFactor);
85 
86 #ifdef DEBUG_UI
87  qDebug() << "B CQBaseWidget::setSlider -> col = " << col << " - row = " << row;
88 #endif
89 
90  mpSliderRow->setValue(row);
91  mpSliderColumn->setValue(col);
92 
93 #ifdef DEBUG_UI
94  qDebug() << "C CQBaseWidget::setSlider -> col = " << mSliderActiveColumn->value() << " - row = " << mSliderActiveRow->value();
95 #endif
96 }
97 
99 {
100  return mScaleFactor;
101 }
void setSlider()
virtual ~CQBaseWidget()
bool isSliderActive() const
CQBaseWidget(QWidget *parent=0, const char *name=0, Qt::WFlags fl=0)
bool mSliderActive
Definition: CQBaseWidget.h:33
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
void setSliderActive(const bool &active)
virtual void sliderMoved(int column, int row)=0