GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoNavigationDockWidget.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 
36 #include <QLabel>
37 #include <QHBoxLayout>
38 #include <QVBoxLayout>
39 #include <QShortcut>
40 
41 #include <QCheckBox>
42 #include <QPushButton>
43 
44 #include <QtDebug>
45 
48  const GoFigure::TabDimensionType & iDim ) :
49  QGoDockWidget(iParent),
50  m_Dimension(iDim)
51 {
52  this->setupUi(this);
53  QIcon Navigation;
54  Navigation.addPixmap(QPixmap( QString::fromUtf8(":/fig/navigation.png") ),
55  QIcon::Normal, QIcon::Off);
56  this->m_ToggleAction->setIcon(Navigation);
57 
58  switch ( m_Dimension )
59  {
60  case GoFigure::TWO_D:
61  {
62  this->XSliceLbl->setVisible(false);
63  this->XSliceSpinBox->setVisible(false);
64  this->YSliceLbl->setVisible(false);
65  this->YSliceSpinBox->setVisible(false);
66  this->ZSliceLbl->setVisible(false);
67  this->ZSliceSpinBox->setVisible(false);
68  this->TSliceLbl->setVisible(false);
69  this->TSliceSpinBox->setVisible(false);
70 
71  break;
72  }
74  {
75  this->XSliceLbl->setVisible(false);
76  this->XSliceSpinBox->setVisible(false);
77  this->YSliceLbl->setVisible(false);
78  this->YSliceSpinBox->setVisible(false);
79  this->ZSliceLbl->setVisible(false);
80  this->ZSliceSpinBox->setVisible(false);
81 
82  break;
83  }
84  case GoFigure::THREE_D:
85  {
86  this->TSliceLbl->setVisible(false);
87  this->TSliceSpinBox->setVisible(false);
88 
89  break;
90  }
91  default:
93  {
94  break;
95  }
96  }
97 
98  QObject::connect( this->XSliceSpinBox, SIGNAL( valueChanged(int) ),
99  this, SIGNAL( XSliceChanged(int) ) );
100 
101  QObject::connect( this->YSliceSpinBox, SIGNAL( valueChanged(int) ),
102  this, SIGNAL( YSliceChanged(int) ) );
103 
104  QObject::connect( this->ZSliceSpinBox, SIGNAL( valueChanged(int) ),
105  this, SIGNAL( ZSliceChanged(int) ) );
106 
107  QObject::connect( this->TSliceSpinBox, SIGNAL( valueChanged(int) ),
108  this, SIGNAL( TSliceChanged(int) ) );
109 
110  // doppler view specific widgets
111  this->channelLabel->hide();
112  this->channelName->hide();
113  this->stepLabel->hide();
114  this->step->hide();
115  this->tLabel->hide();
116  this->t->hide();
117 
118  m_Classic = true;
119 }
120 
121 //-------------------------------------------------------------------------
122 
123 //-------------------------------------------------------------------------
126 {
127 }
128 
129 //-------------------------------------------------------------------------
130 
131 //-------------------------------------------------------------------------
133 {
134  this->XSliceSpinBox->setValue(iSlice);
135 }
136 
137 //-------------------------------------------------------------------------
138 
139 //-------------------------------------------------------------------------
141 {
142  this->YSliceSpinBox->setValue(iSlice);
143 }
144 
145 //-------------------------------------------------------------------------
146 
147 //-------------------------------------------------------------------------
149 {
150  this->ZSliceSpinBox->setValue(iSlice);
151 }
152 
153 //-------------------------------------------------------------------------
154 
155 //-------------------------------------------------------------------------
157 {
158  this->TSliceSpinBox->setValue(iSlice);
159 }
160 
161 //-------------------------------------------------------------------------
162 
163 //-------------------------------------------------------------------------
164 void QGoNavigationDockWidget::SetXMinimumAndMaximum(const int & iMin, const int & iMax)
165 {
166  if( iMin != iMax )
167  {
168  this->XSliceSpinBox->setMinimum(iMin);
169  this->XSliceSpinBox->setMaximum(iMax);
170  this->XSliceSlider->setMinimum(iMin);
171  this->XSliceSlider->setMaximum(iMax);
172  this->MinXSlicelbl->setText( tr("%1").arg(iMin) );
173  this->MaxXSlicelbl->setText( tr("%1").arg(iMax) );
174  }
175  else
176  {
177  this->YSliceLbl->hide();
178  this->YSliceSpinBox->hide();
179  this->YSliceSlider->hide();
180  this->MinYSlicelbl->hide();
181  this->MaxYSlicelbl->hide();
182  }
183 }
184 
185 //-------------------------------------------------------------------------
186 
187 //-------------------------------------------------------------------------
188 void QGoNavigationDockWidget::SetYMinimumAndMaximum(const int & iMin, const int & iMax)
189 {
190  if( iMin != iMax )
191  {
192  this->YSliceSpinBox->setMinimum(iMin);
193  this->YSliceSpinBox->setMaximum(iMax);
194  this->YSliceSlider->setMinimum (iMin);
195  this->YSliceSlider->setMaximum(iMax);
196  this->MinYSlicelbl->setText( tr("%1").arg(iMin) );
197  this->MaxYSlicelbl->setText( tr("%1").arg(iMax) );
198  }
199  else
200  {
201  this->YSliceLbl->hide();
202  this->YSliceSpinBox->hide();
203  this->YSliceSlider->hide();
204  this->MinYSlicelbl->hide();
205  this->MaxYSlicelbl->hide();
206  }
207 }
208 
209 //-------------------------------------------------------------------------
210 
211 //-------------------------------------------------------------------------
212 void QGoNavigationDockWidget::SetZMinimumAndMaximum(const int & iMin, const int & iMax)
213 {
214  if( iMin != iMax )
215  {
216  this->ZSliceSpinBox->setMinimum(iMin);
217  this->ZSliceSpinBox->setMaximum(iMax);
218  this->ZSliceSlider->setMinimum (iMin);
219  this->ZSliceSlider->setMaximum(iMax);
220  this->MinZSlicelbl->setText( tr("%1").arg(iMin) );
221  this->MaxZSlicelbl->setText( tr("%1").arg(iMax) );
222  }
223  else
224  {
225  this->ZSliceLbl->hide();
226  this->ZSliceSpinBox->hide();
227  this->ZSliceSlider->hide();
228  this->MinZSlicelbl->hide();
229  this->MaxZSlicelbl->hide();
230  }
231 }
232 
233 //-------------------------------------------------------------------------
234 
235 //-------------------------------------------------------------------------
236 void QGoNavigationDockWidget::SetTMinimumAndMaximum(const int & iMin, const int & iMax)
237 {
238  if( iMin != iMax )
239  {
240  this->TSliceSpinBox->setMinimum(iMin);
241  this->TSliceSpinBox->setMaximum(iMax);
242  this->TSliceSlider->setMinimum (iMin);
243  this->TSliceSlider->setMaximum(iMax);
244  this->MinTSlicelbl->setText( tr("%1").arg(iMin) );
245  this->MaxTSlicelbl->setText( tr("%1").arg(iMax) );
246 
247  QObject::connect( this->ModeComboBox, SIGNAL( activated(int) ),
248  this, SIGNAL( ModeChanged(int) ) );
249 
250  QObject::connect( this->ModeComboBox, SIGNAL( activated(int) ),
251  this, SLOT( UpdateWidget(int) ) );
252 
253  QObject::connect( this->step, SIGNAL( valueChanged(int) ),
254  this, SIGNAL( StepChanged(int) ) );
255 
256  QObject::connect( this->t, SIGNAL( valueChanged(int) ),
257  this, SIGNAL( DopplerSizeChanged(int) ) );
258  }
259  else
260  {
261  this->TSliceLbl->hide();
262  this->TSliceSpinBox->hide();
263  this->TSliceSlider->hide();
264  this->MinTSlicelbl->hide();
265  this->MaxTSlicelbl->hide();
266  this->ModeComboBox->hide();
267  this->channelLabel->hide();
268  this->channelName->hide();
269  this->stepLabel->hide();
270  this->step->hide();
271  this->tLabel->hide();
272  this->t->hide();
273  }
274 }
275 
276 //-------------------------------------------------------------------------
277 
278 //-------------------------------------------------------------------------
280 {
281  if ( TSliceSpinBox->value() > TSliceSpinBox->minimum() )
282  {
283  emit TSliceChanged(TSliceSpinBox->value() - 1);
284  }
285 }
286 
287 //-------------------------------------------------------------------------
288 
289 //-------------------------------------------------------------------------
291 {
292  if ( TSliceSpinBox->value() < TSliceSpinBox->maximum() )
293  {
294  emit TSliceChanged(TSliceSpinBox->value() + 1);
295  }
296 }
297 
298 //-------------------------------------------------------------------------
299 
300 //-------------------------------------------------------------------------
302 {
303  if ( iStep == 0 )
304  {
305  this->channelLabel->hide();
306  this->channelName->hide();
307  this->stepLabel->hide();
308  this->step->hide();
309  this->tLabel->hide();
310  this->t->hide();
311  }
312  else
313  {
314  this->channelLabel->show();
315  this->channelName->show();
316  this->stepLabel->show();
317  this->step->show();
318  this->tLabel->show();
319  this->t->show();
320  }
321 }
322 //-------------------------------------------------------------------------
323 
324 //-------------------------------------------------------------------------
325 void
327 AddChannel(const QString& iName, const QColor& iColor, const unsigned int& iNumber,
328  const bool& iChecked)
329 {
330  // create check box + colored push button
331  QCheckBox *checkBox1 = new QCheckBox(iName, this);
332  checkBox1->setObjectName(iName);
333  checkBox1->setChecked(iChecked);
334  QString style = "border: 1px solid black; background-color: rgba(%1, %2, %3, 150); border-radius: 4px;";
335  checkBox1->setStyleSheet(
336  style.arg(iColor.red()).arg(iColor .green()).arg(iColor.blue()));
338  layout->addWidget(checkBox1);
339  // to be modified - 7
340  this->gridLayout_2->addLayout(layout, 7+iNumber, 0, 0);
341  //create signals connections
342  QObject::connect( checkBox1, SIGNAL( clicked(bool) ),
343  this, SLOT( visibilityChanged(bool) ) );
344 
345  // vector of widget so we can remove it from layout efficiently
346  m_ListCheckBoxes.push_back(checkBox1);
347 }
348 //-------------------------------------------------------------------------
349 
350 //-------------------------------------------------------------------------
351 void
354 {
355  //modify color of bg of checkbox!
357 
358  // doppler view or not?
359  if(m_Classic)
360  {
361  it2 = m_ListCheckBoxes.begin();
362  }
363  else
364  {
365  it2 = m_ListDoppler.begin();
366  }
367 
368  while(iName.compare((*it2)->objectName()) != 0)
369  {
370  ++it2;
371  }
372 
373  QString style = "border: 1px solid black; background-color: rgba(%1, %2, %3, 150); border-radius: 4px;";
374  (*it2)->setStyleSheet(
375  style.arg(iColor.red()).arg(iColor .green()).arg(iColor.blue()));
376 }
377 //-------------------------------------------------------------------------
378 
379 //-------------------------------------------------------------------------
380 void
382 visibilityChanged(bool iVisibility)
383 {
384  emit visibilityChanged(QObject::sender()->objectName(), iVisibility);
385 }
386 //-------------------------------------------------------------------------
387 
388 //-------------------------------------------------------------------------
389 void
391 VisibilityListChannels(const bool& iVisibility)
392 {
394  while(it != m_ListCheckBoxes.end())
395  {
396  (*it)->setVisible(iVisibility);
397  (*it)->setChecked(iVisibility);
398  ++it;
399  }
400 
402  while(it2 != m_ListPushButtons.end())
403  {
404  (*it2)->setVisible(iVisibility);
405  ++it2;
406  }
407 
408  m_Classic = iVisibility;
409 }
410 //-------------------------------------------------------------------------
411 
412 //-------------------------------------------------------------------------
413 void
415 AddDoppler(const QString& iName, const QColor& iColor, const unsigned int& iNumber,
416  const bool& iChecked)
417 {
418  // create check box + colored push button
419  QCheckBox *checkBox1 = new QCheckBox(iName, this);
420  checkBox1->setObjectName(iName);
421  checkBox1->setChecked(iChecked);
422  QString style = "border: 1px solid black; background-color: rgba(%1, %2, %3, 100); border-radius: 4px;";
423  checkBox1->setStyleSheet(
424  style.arg(iColor.red()).arg(iColor .green()).arg(iColor.blue()));
426  layout->addWidget(checkBox1);
427  // to be modified - 7
428  this->gridLayout_2->addLayout(layout, 7+iNumber, 0, 0);
429  //create signals connections
430  QObject::connect( checkBox1, SIGNAL( clicked(bool) ),
431  this, SLOT( visibilityChanged(bool) ) );
432  // more signals for modify LUT
433 
434  // vector of widget so we can remove it from layout efficiently
435  m_ListDoppler.push_back(checkBox1);
436 }
437 //-------------------------------------------------------------------------
438 
439 //-------------------------------------------------------------------------
440 void
442 VisibilityListDoppler(const bool& iVisibility)
443 {
445  while(it != m_ListDoppler.end())
446  {
447  (*it)->setVisible(iVisibility);
448  ++it;
449  }
450 }
451 //-------------------------------------------------------------------------
452 
453 //-------------------------------------------------------------------------
454 void
456 setChannelName(QString iChannelName)
457 {
458  this->channelName->setText(iChannelName);
459 }
460 //-------------------------------------------------------------------------
461 
462 //-------------------------------------------------------------------------
463 void
465 {
466  qDeleteAll(m_ListDoppler.begin(), m_ListDoppler.end());
468 }
469 //-------------------------------------------------------------------------
470 
471 //-------------------------------------------------------------------------
472 int
475 {
476  int index = 0;
478  while( it2 != m_ListCheckBoxes.end() )
479  {
480  if((*it2)->isChecked())
481  {
482  return index;
483  }
484  ++index;
485  ++it2;
486  }
487  return -1;
488 }
QLayout * layout() const
void clear()
void setStyleSheet(const QString &styleSheet)
void setupUi(QWidget *widget)
void StepChanged(int Step)
void DopplerSizeChanged(int iSize)
void YSliceChanged(int Slice)
void SetZMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the Z direction.
void push_back(const T &value)
QObject * sender() const
void SetXMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the X direction.
QStyle * style() const
void setIcon(const QIcon &icon)
void AddChannel(const QString &iName, const QColor &iColor, const unsigned int &iNumber, const bool &iChecked)
QList< QCheckBox * > m_ListCheckBoxes
QString tr(const char *sourceText, const char *disambiguation, int n)
void setChannelName(QString iChannelName)
void XSliceChanged(int Slice)
void VisibilityListDoppler(const bool &iVisibility)
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
void VisibilityListChannels(const bool &iVisibility)
QString fromUtf8(const char *str, int size)
QList< QPushButton * > m_ListPushButtons
int red() const
void AddDoppler(const QString &iName, const QColor &iColor, const unsigned int &iNumber, const bool &iChecked)
void setObjectName(const QString &name)
void ZSliceChanged(int Slice)
void SetYMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the Y direction.
void addPixmap(const QPixmap &pixmap, Mode mode, State state)
QAction * m_ToggleAction
Definition: QGoDockWidget.h:58
void TSliceChanged(int Slice)
void ModifyChannel(QString iName, QColor iColor)
iterator end()
void SetTMinimumAndMaximum(const int &iMin, const int &iMax)
Set the extent of the images in the Time.
void ModeChanged(int Mode)
void setChecked(bool)
int blue() const
QList< QCheckBox * > m_ListDoppler
GoFigure::TabDimensionType m_Dimension
QGoNavigationDockWidget(QWidget *parent=0, const GoFigure::TabDimensionType &iDim=GoFigure::THREE_D_WITH_T)
Constructor.
inherits from Qt QDockWidget.toggle action reimplemented in order the state is saved when changing ta...
Definition: QGoDockWidget.h:47
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
int compare(const QString &other) const
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
iterator begin()