Public Slots | Public Member Functions | Private Attributes | List of all members
dbutils::gui::BitmapEditor Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-30/DatabaseUtils/cxx/include/GUI/BitmapEditor.h"

Inheritance diagram for dbutils::gui::BitmapEditor:

Public Slots

void selectAll ()
 
void deselectAll ()
 

Public Member Functions

 BitmapEditor (const std::string &initialValue, int bitCount, QWidget *parent=0)
 
std::string getResult () const
 

Private Attributes

bool _inputWasSpecifiedInHex
 
std::vector< QCheckBox * > _checkboxList
 

Detailed Description

Class for providing easier editing of bitmaps.

Author
Kurt Biery
Version
Revision
1.2.28.1
Date
2019/09/27 00:07:04

Definition at line 18 of file BitmapEditor.h.

Constructor & Destructor Documentation

dbutils::gui::BitmapEditor::BitmapEditor ( const std::string initialValue,
int  bitCount,
QWidget *  parent = 0 
)

Definition at line 18 of file BitmapEditor.cpp.

References _checkboxList, _inputWasSpecifiedInHex, HTMLTools::button(), g4zmq::connect(), deselectAll(), makeTrainCVSamples::int, label, novadaq::HexUtils::parse(), selectAll(), string, and make_root_from_grid_output::tr.

18  :
19  QDialog(parent)
20 {
21  setWindowTitle(tr("Bitmap Editor"));
22 
23  // ********************************
24  // first, parse the input value
25  // ********************************
26  int64_t initialValue;
27  if (! novadaq::HexUtils::parse(valueString, initialValue)) {
29  try {
30  initialValue = boost::lexical_cast<int64_t>(valueString);
31  }
32  catch (...) {
33  std::string msgText = "Data Parsing Error: ";
34  msgText.append("Unable to convert value \"");
35  msgText.append(valueString);
36  msgText.append("\" to an integer.");
37  QLabel* label = new QLabel(msgText.c_str());
38 
39  QDialogButtonBox* buttonBox =
40  new QDialogButtonBox(QDialogButtonBox::Cancel);
41  buttonBox->setCenterButtons(true);
42  connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
43 
44  QVBoxLayout *mainLayout = new QVBoxLayout;
45  mainLayout->addWidget(label);
46  mainLayout->addWidget(buttonBox);
47  setLayout(mainLayout);
48 
49  return;
50  }
51  }
52  else {
54  }
55 
56  // ********************************
57  // next, create the checkboxes
58  // ********************************
59  int bitsPerGroup = 8;
60  int nGroups = ((int) ((bitCount - 1) / bitsPerGroup)) + 1;
61  //int nGroups = 4;
62  //int bitsPerGroup = ((int) ((bitCount - 1) / nGroups)) + 1;
63 
64  int64_t _64BitOne = 1;
65  QHBoxLayout* fullBitBox = new QHBoxLayout;
66  int totalCount = 0;
67  for (int igrp = 0; igrp < nGroups; ++igrp) {
68  QVBoxLayout* groupBox = new QVBoxLayout;
69  for (int ibit = 0; ibit < bitsPerGroup; ++ibit) {
70  std::string idxString =
71  boost::lexical_cast<std::string>(totalCount);
72  QCheckBox* cbox = new QCheckBox(idxString.c_str());
73 
74  if ((initialValue & (_64BitOne << totalCount)) != 0) {
75  cbox->setChecked(true);
76  }
77 
78  groupBox->addWidget(cbox);
79  _checkboxList.push_back(cbox);
80 
81  ++totalCount;
82  if (totalCount >= bitCount) {break;}
83  }
84  QWidget* tmpWidget = new QWidget();
85  tmpWidget->setLayout(groupBox);
86  fullBitBox->addWidget(tmpWidget);
87  }
88  QWidget* cboxWidget = new QWidget();
89  cboxWidget->setLayout(fullBitBox);
90 
91  // ********************************
92  // create the select/deselect buttons
93  // ********************************
94  QHBoxLayout* selectButtonBox = new QHBoxLayout;
95  selectButtonBox->addStretch();
96  QPushButton* button = new QPushButton(tr("Select All"));
97  connect(button, SIGNAL(clicked()), this, SLOT(selectAll()));
98  selectButtonBox->addWidget(button);
99  button = new QPushButton(tr("Deselect All"));
100  connect(button, SIGNAL(clicked()), this, SLOT(deselectAll()));
101  selectButtonBox->addWidget(button);
102  selectButtonBox->addStretch();
103 
104  QWidget* selButtonWidget = new QWidget();
105  selButtonWidget->setLayout(selectButtonBox);
106 
107  // ********************************
108  // create the accept/reject buttons
109  // ********************************
110  QDialogButtonBox* buttonBox =
111  new QDialogButtonBox(QDialogButtonBox::Ok |
112  QDialogButtonBox::Cancel);
113  buttonBox->setCenterButtons(true);
114 
115  connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
116  connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
117 
118  // ********************************
119  // put it all together
120  // ********************************
121  QVBoxLayout *mainLayout = new QVBoxLayout;
122  mainLayout->addWidget(selButtonWidget);
123  mainLayout->addWidget(cboxWidget);
124  mainLayout->addWidget(buttonBox);
125  setLayout(mainLayout);
126 }
def button(text, url)
Definition: HTMLTools.py:104
const char * label
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15
std::vector< QCheckBox * > _checkboxList
Definition: BitmapEditor.h:37
bool parse(const std::string &hexString, int32_t &decimalValue)
Definition: HexUtils.cpp:96
enum BeamMode string

Member Function Documentation

void dbutils::gui::BitmapEditor::deselectAll ( )
slot

Definition at line 158 of file BitmapEditor.cpp.

References _checkboxList, compare_h5_caf::idx, and makeTrainCVSamples::int.

Referenced by BitmapEditor().

159 {
160  for (int idx = 0; idx < (int) _checkboxList.size(); ++idx) {
161  _checkboxList[idx]->setChecked(false);
162  }
163 }
std::vector< QCheckBox * > _checkboxList
Definition: BitmapEditor.h:37
std::string dbutils::gui::BitmapEditor::getResult ( ) const

Definition at line 128 of file BitmapEditor.cpp.

References _checkboxList, _inputWasSpecifiedInHex, novadaq::HexUtils::format(), compare_h5_caf::idx, makeTrainCVSamples::int, and string.

129 {
130  int64_t _64BitOne = 1;
131  int64_t workVal = 0;
132  for (int idx = 0; idx < (int) _checkboxList.size(); ++idx) {
133  if (_checkboxList[idx]->isChecked()) {
134  workVal |= (_64BitOne << idx);
135  }
136  }
137 
139  if (_checkboxList.size() > 32) {
140  return novadaq::HexUtils::format(workVal, 16);
141  }
142  else {
143  return novadaq::HexUtils::format(workVal, 8);
144  }
145  }
146  else {
147  return boost::lexical_cast<std::string>(workVal);
148  }
149 }
std::vector< QCheckBox * > _checkboxList
Definition: BitmapEditor.h:37
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
enum BeamMode string
void dbutils::gui::BitmapEditor::selectAll ( )
slot

Definition at line 151 of file BitmapEditor.cpp.

References _checkboxList, compare_h5_caf::idx, and makeTrainCVSamples::int.

Referenced by BitmapEditor().

152 {
153  for (int idx = 0; idx < (int) _checkboxList.size(); ++idx) {
154  _checkboxList[idx]->setChecked(true);
155  }
156 }
std::vector< QCheckBox * > _checkboxList
Definition: BitmapEditor.h:37

Member Data Documentation

std::vector<QCheckBox*> dbutils::gui::BitmapEditor::_checkboxList
private

Definition at line 37 of file BitmapEditor.h.

Referenced by BitmapEditor(), deselectAll(), getResult(), and selectAll().

bool dbutils::gui::BitmapEditor::_inputWasSpecifiedInHex
private

Definition at line 36 of file BitmapEditor.h.

Referenced by BitmapEditor(), and getResult().


The documentation for this class was generated from the following files: