PinController::PinController(GuiController *ui, quint8 pinNumber, QObject *parent) : QObject(parent), pinNumber(pinNumber), ui(ui) { this->groupBox = new QGroupBox(); this->vertSlider = new QSlider(Qt::Vertical); this->maxValue = new QLineEdit(); this->minValue = new QLineEdit(); this->lcd = new QLCDNumber(); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(maxValue); vbox->addWidget(vertSlider); vbox->addWidget(minValue); vbox->addWidget(lcd); //vbox->addStretch(1); groupBox->setLayout(vbox); this->ui->addToTab1Layout(groupBox); groupBox->setTitle(QString("Pin %1").arg(pinNumber)); maxValue->setText(QString::number(defaultMax)); minValue->setText(QString::number(defaultMin)); vertSlider->setRange(defaultMin, defaultMax); // maxValue->setMaxLength(3); // minValue->setMaxLength(3); // QRect maxValueRect = maxValue->geometry(); // maxValueRect.setWidth(41); // maxValue->setGeometry(maxValueRect); //connect(vertSlider, &QSlider::valueChanged, lcd, &QLCDNumber::display); connect(vertSlider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int))); connect(vertSlider, SIGNAL(valueChanged(int)), this, SLOT(sendValueToArduino(int))); connect(this, SIGNAL(sliderValueChanged(Arduino::Buffer)), ui->getArduino(), SLOT(transmitCmd(Arduino::Buffer))); connect(maxValue, SIGNAL(editingFinished()), this, SLOT(updateSliderRange())); connect(minValue, SIGNAL(editingFinished()), this, SLOT(updateSliderRange())); }
DimstackCustomization::DimstackCustomization(XmdvToolMainWnd *mainwnd, QMdiSubWindow *window) : QDialog(window) { //save references to main window, viewManager and pID mainWnd = mainwnd; viewManager = mainWnd->getViewManager(); pID = viewManager->getActiveViewWindow()->getPipelineID(); //get the VisDimstack ViewDisplay *vd = viewManager->getActiveViewWindow()->getViewDisplay();; assert(typeid(*vd) == typeid(VisDimstack)); VisDimstack *visDimstack = dynamic_cast<VisDimstack *>(vd); //use it to set the lengths of the arrays selectionCardinalityLabels.resize(visDimstack->m_dim_size); selectionSliders.resize(visDimstack->m_dim_size); //set default value of 10 for maximum bins in a dimension maxBins = 10; //set up the dialog if (objectName().isEmpty()) setObjectName(QString::fromUtf8("dimstackCustomizationDialog")); resize(300,360); //setFixedSize(QSize::QSize (300, 360)); setWindowTitle(QString::fromUtf8("Dimension Stacking Customization")); setAttribute(Qt::WA_DeleteOnClose, false); windowLayout = new QGridLayout(this); maxBinsLabel = new QLabel(this); maxBinsLabel->setObjectName(QString::fromUtf8("maxBinsLabel")); maxBinsLabel->setText(QString::fromUtf8("Maximum Number of Bins")); //maxBinsLabel->setGeometry(QRect(10, 10, 121, 16)); windowLayout->addWidget(maxBinsLabel, 0, 0); binSelectionArea = new QScrollArea(this); binSelectionArea->setObjectName(QString::fromUtf8("binSelectionArea")); //binSelectionArea->setGeometry(QRect(9, 39, 290, 280)); windowLayout->addWidget(binSelectionArea, 1, 0, 1, -1); selectionAreaContents = new QWidget(binSelectionArea); selectionTable = new QFormLayout(); selectionTable->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); //add the top row to the selection table nameTitle = new QLabel(selectionAreaContents); nameTitle->setObjectName(QString::fromUtf8("nameTitle")); nameTitle->setText(QString::fromUtf8("Fieldname")); nameTitle->setFrameStyle(QFrame::Panel | QFrame::Raised); numBinsTitle = new QLabel(selectionAreaContents); numBinsTitle->setObjectName(QString::fromUtf8("numBinsTitle")); numBinsTitle->setText(QString::fromUtf8("Number of Bins")); numBinsTitle->setFrameStyle(QFrame::Panel | QFrame::Raised); //selectionTable->setVerticalSpacing(0); selectionTable->addRow(nameTitle, numBinsTitle); //dynamically add the rest of the rows here //(and while we're at it we set maxBins to the highest cardinality // of a dimension if it exceeds the default of 10) initRows(visDimstack); //set the layout after it has been populated //and set the contents of the scroll area selectionAreaContents->setLayout(selectionTable); binSelectionArea->setWidget(selectionAreaContents); //now maxBins is equal to the maximum number of bins of all dimensions in the dataset //generate the field for specifying max number of bins maxBinsEdit = new QLineEdit(this); maxBinsEdit->setObjectName(QString::fromUtf8("maxBinsEdit")); maxBinsEdit->setText(QString::number(maxBins)); //maxBinsEdit->setGeometry(QRect(140, 10, 113, 20)); windowLayout->addWidget(maxBinsEdit, 0, 1); //connect the max number of bins specified to the max range of the slider connect(maxBinsEdit, SIGNAL(returnPressed()), this, SLOT(updateSliderRange())); applyButton = new QPushButton(this); applyButton->setObjectName(QString::fromUtf8("applyButton")); applyButton->setText(QString::fromUtf8("Apply")); applyButton->setDefault(false); //applyButton->setGeometry(QRect(10, 330, 161, 24)); windowLayout->addWidget(applyButton, 2, 0); connect(applyButton, SIGNAL(clicked()), this, SLOT(applyChanges())); windowLayout->setVerticalSpacing(4); setLayout(windowLayout); }