Optika GUI Toolik  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Optika_ArrayWidget.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Optika: A Tool For Developing Parameter Obtaining GUIs
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com)
38 //
39 // ***********************************************************************
40 // @HEADER
41 #ifndef OPTIKA_ARRAYWIDGET_HPP_
42 #define OPTIKA_ARRAYWIDGET_HPP_
43 
44 #include <QDialog>
45 #include <QModelIndex>
46 #include <QPushButton>
47 #include <QGridLayout>
48 #include <QDoubleSpinBox>
49 #include <QComboBox>
50 #include <QLineEdit>
51 #include <QGridLayout>
52 #include <QScrollArea>
53 #include <QLabel>
54 #include <vector>
55 #include "Optika_treemodel.hpp"
58 
64 namespace Optika {
65 
73 template<class S>
74 class GenericArrayWidget : public QDialog{
75 
76 public:
77 
81 
91  QString name,
92  QString type,
93  const RCP<const ParameterEntryValidator> validator,
94  QWidget *parent=0);
96 
102  const QString getType() const {
103  return type;
104  }
105 
109  const QString getName() const{
110  return name;
111  }
112 
117  return entryValidator;
118  }
119 
125  virtual void accept() =0;
126 
127 
128 protected:
129 
132  //@[
133 
138  virtual void setupArrayLayout(){
139  if(arrayContainer->layout() == NULL){
140  arrayContainer->setLayout(getArrayLayout());
141  }
142  }
143 
151  virtual QLayout* getArrayLayout() =0;
152 
156  virtual void doAcceptWork() =0;
157 
158 
160 
163 
168  QWidget *arrayContainer;
169 
171 
172 
173 private:
174 
177 
181  QString type;
182 
186  QString name;
187 
192 
194 };
195 
196 template<class S>
198  QString name,
199  QString type,
200  const RCP<const ParameterEntryValidator> validator,
201  QWidget *parent):
202  QDialog(parent),
203  type(type),
204  name(name),
205  entryValidator(validator)
206 {
207  setModal(true);
208  setSizeGripEnabled(true);
209  arrayContainer = new QWidget(this);
210 
211  QScrollArea *scrollArea = new QScrollArea(this);
212  scrollArea->setWidget(arrayContainer);
213  scrollArea->setWidgetResizable(true);
214 
215  QPushButton *doneButton = new QPushButton(tr("Done"));
216  QPushButton *cancelButton = new QPushButton(tr("Cancel"));
217  connect(doneButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
218  connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(reject()));
219  QGridLayout *layout = new QGridLayout(this);
220  layout->addWidget(scrollArea,0,0,1,3);
221  layout->addWidget(doneButton,1,2);
222  layout->addWidget(cancelButton,1,1);
223 
224  this->setLayout(layout);
225 
226  setWindowTitle(name);
227 }
228 
234 template <class S>
236 
237 public:
238 
241 
251  QString name,
252  QString type,
253  const RCP<const ParameterEntryValidator> validator,
254  QWidget *parent=0);
255 
257 
260 
270  void initData(TwoDArray<S> array){
271  baseArray = array;
272  this->setupArrayLayout();
273  }
274 
287  TwoDArray<S> toReturn(
288  numRows, numCols);
289  int numColsToIterate =0;
290  for(int i=0; i<numRows; ++i){
291  numColsToIterate = baseArray.isSymmetrical() ?
292  numCols-numRows+i : numCols;
293  for(int j=0; j<numColsToIterate; ++j){
294  toReturn(i,j) = getWidgetValue(i+1,j+1);
295  }
296  }
298  return toReturn;
299  }
300 
306  virtual S getWidgetValue(int row, int col) = 0;
307 
311  inline TwoDArray<S> getData() const{
312  return baseArray;
313  }
314 
316 
317 protected:
318 
321 
328  void doAcceptWork(){
329  baseArray.clear();
331  this->done(QDialog::Accepted);
332  }
333 
343  virtual QWidget* getEditorWidget(int row, int col) =0;
344 
346 
349 
355 
362 
364 
365 private:
366 
369 
373  QLayout* getArrayLayout();
374 
375 };
376 
377 template<class S>
379  QString name,
380  QString type,
381  const RCP<const ParameterEntryValidator> validator,
382  QWidget *parent):
383  GenericArrayWidget<S>(name, type, validator, parent)
384 {}
385 
386 
387 template<class S>
389  widgetArray = TwoDArray<QWidget*>(baseArray.getNumRows()+1, baseArray.getNumCols()+1);
390  QGridLayout *widgetLayout = new QGridLayout;
391  for(int i =0; i < baseArray.getNumCols(); ++i){
392  widgetLayout->addWidget(new QLabel("Column: " +QString::number(i)),0,i+1,Qt::AlignLeft);
393  }
394  for(int i =0; i < baseArray.getNumRows(); ++i){
395  widgetLayout->addWidget(new QLabel("Row: " +QString::number(i)),i+1,0,Qt::AlignLeft);
396  }
397  int numColsToIterate =0;
398  for(int i =0; i < baseArray.getNumRows(); ++i){
399  numColsToIterate = baseArray.isSymmetrical() ?
400  baseArray.getNumCols()-baseArray.getNumRows()+i : baseArray.getNumCols();
401  for(int j =0; j < numColsToIterate; ++j){
402  QWidget* editorWidget = getEditorWidget(i,j);
403  widgetLayout->addWidget(editorWidget,i+1,j+1,Qt::AlignLeft);
404  widgetArray(i+1,j+1) = editorWidget;
405  }
406  }
407  return widgetLayout;
408 }
409 
414 Q_OBJECT
415 public:
416 
419 
429  QString name,
430  QString type,
431  const RCP<const ParameterEntryValidator> validator,
432  QWidget *parent=0):
433  Generic2DArrayWidget<int>(name, type, validator, parent)
434  {}
435 
436 
439 
441  inline int getWidgetValue(int row, int col){
442  return ((QSpinBox*)widgetArray(row,col))->value();
443  }
444 
445 protected:
446 
448  QWidget* getEditorWidget(int row, int col){
449  QSpinBox *newSpin = new QSpinBox(this);
450  RCP<const EnhancedNumberValidator<int> > validator = null;
451  if(!is_null(getEntryValidator())){
452  validator = rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<int>, int> >(getEntryValidator(),true)->getPrototype();
453  }
454  ValidatorApplier<int>::applyToSpinBox(validator, newSpin);
455  newSpin->setValue(baseArray(row, col));
456  return newSpin;
457  }
458 
460 
461 public slots:
464 
466  void accept(){
467  doAcceptWork();
468  }
469 
471 
472 };
473 
478 Q_OBJECT
479 public:
480 
483 
493  QString name,
494  QString type,
495  const RCP<const ParameterEntryValidator> validator,
496  QWidget *parent=0):
497  Generic2DArrayWidget<short>(name, type, validator, parent)
498  {}
499 
501 
504 
506  inline short getWidgetValue(int row, int col){
507  return ((QSpinBox*)widgetArray(row,col))->value();
508  }
509 
510 protected:
511 
513  QWidget* getEditorWidget(int row, int col){
514  QSpinBox *newSpin = new QSpinBox(this);
515  RCP<const EnhancedNumberValidator<short> > validator = null;
516  if(!is_null(getEntryValidator())){
517  validator = rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<short>, short> >(getEntryValidator(),true)->getPrototype();
518  }
519  ValidatorApplier<short>::applyToSpinBox(validator, newSpin);
520  newSpin->setValue(baseArray(row, col));
521  return newSpin;
522  }
523 
525 
526 public slots:
527 
530 
532  void accept(){
533  doAcceptWork();
534  }
535 
537 
538 };
539 
544 Q_OBJECT
545 public:
546 
549 
559  QString name,
560  QString type,
561  const RCP<const ParameterEntryValidator> validator,
562  QWidget *parent=0):
563  Generic2DArrayWidget<double>(name, type, validator, parent)
564  {}
565 
567 
570 
572  inline double getWidgetValue(int row, int col){
573  return ((QLineEdit*)widgetArray(row,col))->text().toDouble();
574  }
575 
576 protected:
577 
579  QWidget* getEditorWidget(int row, int col){
580  QLineEdit *newEdit = new QLineEdit(this);
582  if(!is_null(getEntryValidator())){
583  validator = rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<double>, double> >(getEntryValidator(),true)->getPrototype();
584  }
585  ValidatorApplier<double>::applyToLineEdit(validator, newEdit);
586  newEdit->setText(QString::number(baseArray(row,col)));
587  return newEdit;
588  }
589 
591 
592 public slots:
593 
596 
597  void accept(){
598  doAcceptWork();
599  }
600 
602 
603 };
604 
609 Q_OBJECT
610 public:
611 
614 
624  QString name,
625  QString type,
626  const RCP<const ParameterEntryValidator> validator,
627  QWidget *parent=0):
628  Generic2DArrayWidget<float>(name, type, validator, parent)
629  {}
630 
632 
635 
637  inline float getWidgetValue(int row, int col){
638  return ((QLineEdit*)widgetArray(row,col))->text().toDouble();
639  }
640 
641 protected:
642 
644  QWidget* getEditorWidget(int row, int col){
645  QLineEdit *newEdit = new QLineEdit(this);
646  RCP<const EnhancedNumberValidator<float> > validator = null;
647  if(!is_null(getEntryValidator())){
648  validator = rcp_dynamic_cast<const TwoDArrayValidator<EnhancedNumberValidator<float>, float> >(getEntryValidator(),true)->getPrototype();
649  }
650  ValidatorApplier<float>::applyToLineEdit(validator, newEdit);
651  newEdit->setText(QString::number(baseArray(row,col)));
652  return newEdit;
653  }
654 
656 
657 public slots:
658 
661 
662  void accept(){
663  doAcceptWork();
664  }
665 
667 
668 };
669 
673 class String2DArrayWidget : public Generic2DArrayWidget<std::string>{
674 Q_OBJECT
675 public:
676 
679 
689  QString name,
690  QString type,
691  const RCP<const ParameterEntryValidator> validator,
692  QWidget *parent=0):
693  Generic2DArrayWidget<std::string>(name, type, validator, parent)
694  {}
695 
697 
700 
702  std::string getWidgetValue(int row, int col){
703  if(is_null(getEntryValidator())){
704  return ((QLineEdit*)widgetArray(row,col))->text().toStdString();
705  }
706  else if(!is_null(rcp_dynamic_cast<const ArrayValidator<FileNameValidator, std::string> >(getEntryValidator()))){
707  return ((FileNameWidget*)widgetArray(row,col))->getCurrentFileName().toStdString();
708  }
709  else if(getEntryValidator()->validStringValues()->size() !=0){
710  return ((QComboBox*)widgetArray(row,col))->currentText().toStdString();
711  }
712  else{
713  return ((QLineEdit*)widgetArray(row,col))->text().toStdString();
714  }
715  }
716 
717 protected:
718 
720  QWidget* getEditorWidget(int row, int col){
721  QString currentData = QString::fromStdString(baseArray(row,col));
722  if(is_null(getEntryValidator())){
723  return new QLineEdit(currentData,this);
724  }
726  return new FileNameWidget(
727  currentData,
728  rcp_dynamic_cast<const TwoDArrayValidator<FileNameValidator, std::string> >(getEntryValidator())->getPrototype()->fileMustExist(), this);
729  }
730  else if(getEntryValidator()->validStringValues()->size() != 0){
731  RCP<const Array<std::string> > options = getEntryValidator()->validStringValues();
732  QComboBox *newCombo = new QComboBox(this);
733  for(Array<std::string>::const_iterator itr = options->begin(); itr != options->end(); ++itr){
734  newCombo->addItem(QString::fromStdString(*itr));
735  }
736  int selectedItem = newCombo->findText(currentData);
737  newCombo->setCurrentIndex(selectedItem);
738  return newCombo;
739  }
740  else{
741  return new QLineEdit(currentData,this);
742  }
743  }
744 
746 
747 public slots:
750 
752  void accept(){
753  doAcceptWork();
754  }
755 
757 
758 };
759 
765 template <class S>
767 public:
768 
771 
781  QString name,
782  QString type,
783  const RCP<const ParameterEntryValidator> validator,
784  QWidget *parent=0);
785 
787 
789 
790 
791 
797  const Array<S> getData() const{
798  return baseArray;
799  }
800 
802 
803 
806 
816  void initData(Array<S> array){
817  baseArray = array;
818  this->setupArrayLayout();
819  }
820 
824  virtual QWidget* getEditorWidget(int index) = 0;
825 
831  virtual Array<S> getArrayFromWidgets() = 0;
832 
833 
835 
836 protected:
837 
840 
844  typedef std::vector<QWidget*> WVector;
845 
847 
850 
855 
860 
862 
865 
867  void doAcceptWork();
868 
870 
871 private:
872 
875 
876  QLayout* getArrayLayout();
877 
879 };
880 
881 template<class S>
883  QString name,
884  QString type,
885  const RCP<const ParameterEntryValidator> validator,
886  QWidget *parent):
887  GenericArrayWidget<S>(name, type, validator, parent)
888 {}
889 
890 
891 template<class S>
893  QGridLayout *widgetLayout = new QGridLayout;
894  for(int i=0; i<baseArray.size(); ++i){
895  widgetLayout->addWidget(new QLabel("Item: " +QString::number(i)),0,i,Qt::AlignLeft);
896  QWidget* editorWidget = getEditorWidget(i);
897  widgetLayout->addWidget(editorWidget,1,i,Qt::AlignLeft);
898  widgetVector.push_back(editorWidget);
899  }
900  return widgetLayout;
901 }
902 
903 template<class S>
905  baseArray.clear();
906  baseArray = getArrayFromWidgets();
907  this->done(QDialog::Accepted);
908 }
909 
914  Q_OBJECT
915 public:
916 
919 
929  QString name,
930  QString type,
931  const RCP<const ParameterEntryValidator> validator,
932  QWidget *parent=0):
933  Generic1DArrayWidget<int>(name, type, validator,parent){}
934 
936 
939 
944  Array<int> toReturn(widgetVector.size(), 0);
945  for(size_t i=0; i < widgetVector.size(); ++i){
946  toReturn[i]= ((QSpinBox*)widgetVector[i])->value();
947  }
948  return toReturn;
949  }
950 
951 private:
952 
956  QWidget* getEditorWidget(int index){
957  QSpinBox *newSpin = new QSpinBox(this);
958  RCP<const EnhancedNumberValidator<int> > validator = null;
959  if(!is_null(getEntryValidator())){
960  validator = rcp_dynamic_cast<const ArrayValidator<EnhancedNumberValidator<int>, int> >(getEntryValidator(),true)->getPrototype();
961  }
962  ValidatorApplier<int>::applyToSpinBox(validator, newSpin);
963  newSpin->setValue(baseArray[index]);
964  return newSpin;
965  }
966 
968 
969 
970 public slots:
971 
974 
976  void accept(){
977  doAcceptWork();
978  }
979 
981 
982 };
983 
988 {
989  Q_OBJECT
990 public:
991 
994 
1004  QString name,
1005  QString type,
1006  const RCP<const ParameterEntryValidator> validator,
1007  QWidget *parent=0):
1008  Generic1DArrayWidget<short>(name, type, validator,parent){}
1009 
1011 
1014 
1017  Array<short> toReturn(widgetVector.size(), 0);
1018  for(size_t i=0; i < widgetVector.size(); ++i){
1019  toReturn[i]= ((QSpinBox*)widgetVector[i])->value();
1020  }
1021  return toReturn;
1022  }
1023 
1024 
1025 private:
1026 
1028  QWidget* getEditorWidget(int index){
1029  QSpinBox *newSpin = new QSpinBox(this);
1030  RCP<const EnhancedNumberValidator<short> > validator = null;
1031  if(!is_null(getEntryValidator())){
1032  validator = rcp_dynamic_cast<const ArrayValidator<EnhancedNumberValidator<short>, short> >(getEntryValidator(),true)->getPrototype();
1033  }
1034  ValidatorApplier<short>::applyToSpinBox(validator, newSpin);
1035  newSpin->setValue(baseArray[index]);
1036  return newSpin;
1037  }
1038 
1040 
1041 public slots:
1044 
1046  void accept(){
1047  doAcceptWork();
1048  }
1049 
1051 };
1052 
1057 {
1058  Q_OBJECT
1059 public:
1060 
1063 
1073  QString name,
1074  QString type,
1075  const RCP<const ParameterEntryValidator> validator,
1076  QWidget *parent=0):
1077  Generic1DArrayWidget<double>(name, type, validator,parent){}
1078 
1080 
1083 
1086  Array<double> toReturn(widgetVector.size(), 0.0);
1087  for(size_t i=0; i < widgetVector.size(); ++i){
1088  toReturn[i]= ((QLineEdit*)widgetVector[i])->text().toDouble();
1089  }
1090  return toReturn;
1091  }
1092 
1093 private:
1094 
1096  QWidget* getEditorWidget(int index){
1097  QLineEdit *newEdit = new QLineEdit(this);
1098  RCP<const EnhancedNumberValidator<double> > validator = null;
1099  if(!is_null(getEntryValidator())){
1100  validator = rcp_dynamic_cast<const ArrayValidator<EnhancedNumberValidator<double>, double> >(getEntryValidator(),true)->getPrototype();
1101  }
1102  ValidatorApplier<double>::applyToLineEdit(validator, newEdit);
1103  newEdit->setText(QString::number(baseArray[index], 'g', ((QDoubleValidator*)newEdit->validator())->decimals()));
1104  return newEdit;
1105  }
1106 
1108 
1109 public slots:
1112 
1114  void accept(){
1115  doAcceptWork();
1116  }
1117 
1119 
1120 };
1121 
1126 {
1127  Q_OBJECT
1128 public:
1131 
1141  QString name,
1142  QString type,
1143  const RCP<const ParameterEntryValidator> validator,
1144  QWidget *parent=0):
1145  Generic1DArrayWidget<float>(name, type, validator,parent){}
1146 
1148 
1151 
1154  Array<float> toReturn(widgetVector.size(), 0.0);
1155  for(size_t i=0; i < widgetVector.size(); ++i){
1156  toReturn[i]= ((QLineEdit*)widgetVector[i])->text().toDouble();
1157  }
1158  return toReturn;
1159  }
1160 
1161 private:
1162 
1164  QWidget* getEditorWidget(int index){
1165  QLineEdit *newEdit = new QLineEdit(this);
1166  RCP<const EnhancedNumberValidator<float> > validator = null;
1167  if(!is_null(getEntryValidator())){
1168  validator = rcp_dynamic_cast<const ArrayValidator<EnhancedNumberValidator<float>, float> >(getEntryValidator(),true)->getPrototype();
1169  }
1170  ValidatorApplier<float>::applyToLineEdit(validator, newEdit);
1171  newEdit->setText(QString::number(baseArray[index], 'g', ((QDoubleValidator*)newEdit->validator())->decimals()));
1172  return newEdit;
1173  }
1174 
1175 
1177 
1178 public slots:
1179 
1182 
1184  void accept(){
1185  doAcceptWork();
1186  }
1187 
1189 
1190 };
1191 
1195 class StringArrayWidget : public Generic1DArrayWidget<std::string>{
1196  Q_OBJECT
1197 public:
1198 
1201 
1211  QString name,
1212  QString type,
1213  const RCP<const ParameterEntryValidator> validator,
1214  QWidget *parent=0):
1215  Generic1DArrayWidget<std::string>(name, type, validator,parent)
1216  {}
1217 
1219 
1222 
1225  Array<std::string> toReturn(widgetVector.size(), "");
1226  for(size_t i=0; i < widgetVector.size(); ++i){
1227  if(is_null(getEntryValidator())){
1228  toReturn[i] = ((QLineEdit*)widgetVector[i])->text().toStdString();
1229  }
1230  else if(!is_null(rcp_dynamic_cast<const ArrayValidator<FileNameValidator, std::string> >(getEntryValidator()))){
1231  toReturn[i] = ((FileNameWidget*)widgetVector[i])->getCurrentFileName().toStdString();
1232  }
1233  else if(getEntryValidator()->validStringValues()->size() !=0){
1234  toReturn[i] = ((QComboBox*)widgetVector[i])->currentText().toStdString();
1235  }
1236  else{
1237  toReturn[i] = ((QLineEdit*)widgetVector[i])->text().toStdString();
1238  }
1239  }
1240  return toReturn;
1241  }
1242 
1243 private:
1244 
1246  QWidget* getEditorWidget(int index){
1247  QString currentData = QString::fromStdString(baseArray[index]);
1248  if(is_null(getEntryValidator())){
1249  return new QLineEdit(currentData,this);
1250  }
1251  else if(!is_null(rcp_dynamic_cast<const ArrayValidator<FileNameValidator, std::string> >(getEntryValidator()))){
1252  return new FileNameWidget(
1253  currentData,
1254  rcp_dynamic_cast<const ArrayValidator<FileNameValidator, std::string> >(getEntryValidator())->getPrototype()->fileMustExist(), this);
1255  }
1256  else if(getEntryValidator()->validStringValues()->size() != 0){
1257  RCP<const Array<std::string> > options = getEntryValidator()->validStringValues();
1258  QComboBox *newCombo = new QComboBox(this);
1259  for(Array<std::string>::const_iterator itr = options->begin(); itr != options->end(); ++itr){
1260  newCombo->addItem(QString::fromStdString(*itr));
1261  }
1262  int selectedItem = newCombo->findText(currentData);
1263  newCombo->setCurrentIndex(selectedItem);
1264  return newCombo;
1265  }
1266  else{
1267  return new QLineEdit(currentData,this);
1268  }
1269  }
1270 
1272 
1273 public slots:
1274 
1277 
1279  void accept(){
1280  doAcceptWork();
1281  }
1282 
1284 
1285 
1286 };
1287 
1288 
1289 } //end namespace
1290 #endif //OPTIKA_ARRAYWIDGET_HPP_
virtual void doAcceptWork()=0
Gathers all the user inputed data and closes the dialog.
virtual void accept()=0
called when the user is done entering data into the widget. MUST BE IMPLEMENTED AS A SLOT IN CONCRETE...
A 2DArrayWidget used for editing arrays whose template type is short.
A widget for editing an array of strings.
GenericArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a GenericArrayWidget.
void doAcceptWork()
Do all the things that need to be done when accept is called.
QWidget * getEditorWidget(int index)
QWidget * getEditorWidget(int row, int col)
bool is_null(const boost::shared_ptr< T > &p)
std::vector< QWidget * > WVector
Convienece typedef. Represents an array of QWidgets.
virtual void setupArrayLayout()
Sets up the layout for the arrayContainer, including adding what ever editing widget should be used f...
Array< int > getArrayFromWidgets()
A 2DArrayWidget used for editing arrays whose template type is std::string.
RCP< const ParameterEntryValidator > entryValidator
The validator being used on the array.
void setSymmetrical(bool symmetrical)
QWidget * getEditorWidget(int row, int col)
TwoDArray< S > baseArray
The actual array data that the widget is editing. When the user is finished editing, this TwoDArray is then populated with the values they entered.
TwoDArray< QWidget * > widgetArray
An array containing the individual widgets which make up the array widget editor. The widget at row...
virtual QLayout * getArrayLayout()=0
Get's the layout to be used for the array container in the widget.
const Array< S > getData() const
IntArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a IntArrayWidget.
QWidget * arrayContainer
The widget containing all of the editing widgets (e.g. QLineEdits, and QSpinBoxes) that comprise the ...
Array< double > getArrayFromWidgets()
A templated abstract base class for all 1D array editing widgets.
Array< S > baseArray
The array to be edited.
A 2DArrayWidget used for editing arrays whose template type is float.
A widget for editing Arrays of type short.
A 1D widget for editing Arrays of type int.
A 2DArrayWidget used for editing arrays whose template type is double.
virtual S getWidgetValue(int row, int col)=0
Gets the current value entred in the widget located at row,col.
const QString getType() const
Gets the type of array being edited.
A 2DArrayWidget used for editing arrays whose template type is int.
QWidget * getEditorWidget(int index)
Generic2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a Generic2DArrayWidget.
QWidget * getEditorWidget(int index)
StringArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a StringArrayWidget.
float getWidgetValue(int row, int col)
const QString getName() const
Returns the name of the parameter being edits.
double getWidgetValue(int row, int col)
QWidget * getEditorWidget(int index)
void initData(Array< S > array)
Initializes all of the data in the array widget so when it pops up, the individual widgets are popula...
short getWidgetValue(int row, int col)
std::string getWidgetValue(int row, int col)
QLayout * getArrayLayout()
Retrieves the layout to be used in the array container.
FloatArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a FloatArrayWidget.
size_type getNumCols() const
const RCP< const ParameterEntryValidator > getEntryValidator() const
Returns the validator being used on the array.
int getWidgetValue(int row, int col)
A widget for editing Arrays of type short.
ShortArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a ShortArrayWidget.
DoubleArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a DoubleArrayWidget.
An Abstract base class for both 2D and 1D ArrayWidgets.
size_type getNumRows() const
Array< float > getArrayFromWidgets()
void initData(TwoDArray< S > array)
Initializes all of the data in the array widget so when it pops up, the individual widgets are popula...
Array< std::string > getArrayFromWidgets()
static void applyToSpinBox(RCP< const EnhancedNumberValidator< S > > validator, QSpinBox *spinBox)
Applied attributes of the validator to the spin box.
Short2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs an Short2DArrayWidget.
QWidget * getEditorWidget(int row, int col)
QWidget * getEditorWidget(int index)
Int2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs an Int2DArrayWidget.
A widget for editing Arrays of type double.
String2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs an String2DArrayWidget.
QLayout * getArrayLayout()
Get's the layout to be used for the array container in the widget.
virtual QWidget * getEditorWidget(int index)=0
Gets the widget to be used as an editor for each entry in the array.
QWidget * getEditorWidget(int row, int col)
QString type
The type of array.
static void applyToLineEdit(RCP< const EnhancedNumberValidator< S > > validator, QLineEdit *lineEdit)
Generic1DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs a Generic1DArrayWidget.
bool isSymmetrical() const
TwoDArray< S > getArrayFromWidgets()
Retrieves all the data currently entered in each of the individual widgets and compiles it into a Two...
Array< short > getArrayFromWidgets()
Double2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs an Double2DArrayWidget.
A widget used to obtain file information in Optika.
QWidget * getEditorWidget(int row, int col)
WVector widgetVector
Conatins the editing widgets (e.g. QLineEdits and QSpinBoxes) comprising the array editor...
A small widget consisting of a button and label that allows the user to select a file through a QFile...
virtual Array< S > getArrayFromWidgets()=0
Get a new array reflecting the current values entered in the widgets.
virtual QWidget * getEditorWidget(int row, int col)=0
Float2DArrayWidget(QString name, QString type, const RCP< const ParameterEntryValidator > validator, QWidget *parent=0)
Constructs an Float2DArrayWidget.
A collection of objects which apply the restriction of a EnhancedNumberValidator to a SpinBoxes and L...
TwoDArray< S > getData() const
gets the data currently stored in baseArray.
An abstract base class for all 2D Array Widets.