GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoColorCodingDialog.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 #include "QGoColorCodingDialog.h"
35 #include <QLabel>
36 #include <QRadioButton>
37 #include <QVBoxLayout>
38 
40  bool iRandomIncluded,
41  QWidget *iParent) : QDialog(iParent)
42 {
43  this->SetUpUi(iTraceName, iRandomIncluded);
44 }
45 
46 //-------------------------------------------------------------------------
47 
48 //-------------------------------------------------------------------------
50 {
51 }
52 
53 //-------------------------------------------------------------------------
54 
55 //-------------------------------------------------------------------------
57 {
58  this->m_LUT = QGoLUTDialog::GetLookupTable( this,
59  tr("Choose your range of colors") );
60  if ( this->m_LUT != NULL )
61  {
62  this->accept();
63  }
64 }
65 
66 //-------------------------------------------------------------------------
67 
68 //-------------------------------------------------------------------------
69 void QGoColorCodingDialog::SetUpUi(std::string iTraceName,
70  bool iRandomIncluded)
71 {
72  QLabel *ChooseYourWay = new QLabel( tr("Choose how you want to color your %1s :").arg( iTraceName.c_str() ) );
73 
74  m_DefaultButton = new QRadioButton(tr("Default"), this);
76  m_LUTButton = new QRadioButton(tr("Choose a range of colors"), this);
77 
78  QVBoxLayout *VLayout = new QVBoxLayout(this);
79  VLayout->addWidget(ChooseYourWay);
80  VLayout->addWidget(m_DefaultButton);
81  VLayout->addWidget(m_LUTButton);
82 
83  if ( iRandomIncluded )
84  {
85  m_RandomButton = new QRadioButton(tr("Randomly"), this);
86  VLayout->addWidget(m_RandomButton);
87  }
88 
89  QDialogButtonBox *ButtonBox = new QDialogButtonBox(this);
90  ButtonBox->setStandardButtons(QDialogButtonBox::Cancel
91  | QDialogButtonBox::Ok);
92  VLayout->addWidget(ButtonBox);
93 
94  QObject::connect( this->m_LUTButton, SIGNAL( clicked() ), this, SLOT( OpenLUTDialog() ) );
95  QObject::connect( ButtonBox, SIGNAL( accepted() ),
96  this, SLOT( accept() ) );
97  QObject::connect( ButtonBox, SIGNAL( rejected() ),
98  this, SLOT( reject() ) );
99 }
100 
101 //-------------------------------------------------------------------------
102 
103 //-------------------------------------------------------------------------
106  std::string iTraceName, vtkLookupTable **ioLUT,
107  bool iRandomIncluded, QWidget *iiParent)
108 {
109  QGoColorCodingDialog *ColorDialog =
110  new QGoColorCodingDialog(iTraceName, iRandomIncluded, iiParent);
111 
113 
114  if ( ColorDialog->exec() == QDialog::Accepted )
115  {
116  if ( ColorDialog->m_DefaultButton->isChecked() )
117  {
119  }
120  if ( iRandomIncluded )
121  {
122  if ( ColorDialog->m_RandomButton->isChecked() )
123  {
124  oNameWay = QGoColorCodingDialog::Random;
125  }
126  }
127  if ( ColorDialog->m_LUTButton->isChecked() )
128  {
129  oNameWay = QGoColorCodingDialog::LUT;
130  *ioLUT = ColorDialog->m_LUT;
131  ColorDialog->accept();
132  }
133  }
134 
135  return oNameWay;
136 }
virtual void reject()
virtual ~QGoColorCodingDialog()
Destructor.
void rejected()
void accepted()
int exec()
QString tr(const char *sourceText, const char *disambiguation, int n)
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
vtkLookupTable * GetLookupTable()
get the selected look up table
QRadioButton * m_RandomButton
virtual void accept()
void OpenLUTDialog()
open tha QGoLUTDialog to let the user choose a LUT
void setChecked(bool)
void setStandardButtons(QFlags< QDialogButtonBox::StandardButton > buttons)
static ColorWay GetColorWay(std::string iTraceName, vtkLookupTable **ioLUT, bool iRandomIncluded, QWidget *iiParent=0)
get the way the user wants its traces to be colorcoded and the LUT if he chooses the LUT ...
QRadioButton * m_DefaultButton
void SetUpUi(std::string iTraceName, bool iRandomIncluded)
set the components of the widget and the connection
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This dialog asks the user to chose the way he wants its traces to be colorcoded.
QGoColorCodingDialog(std::string iTraceName, bool iRandomIncluded, QWidget *iParent=0)
Constructor.