AntialiasPopup::AntialiasPopup() : Dialog(TApp::instance()->getMainWindow(), true, false, "Antialias"), m_startRas(0) { setWindowTitle(tr("Apply Antialias")); setLabelWidth(0); setModal(false); setTopMargin(0); setTopSpacing(0); beginVLayout(); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); addWidget(splitter); endVLayout(); //------------------------- Top Layout -------------------------- QScrollArea *scrollArea = new QScrollArea(splitter); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setWidgetResizable(true); splitter->addWidget(scrollArea); splitter->setStretchFactor(0, 1); QFrame *topWidget = new QFrame(scrollArea); topWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); scrollArea->setWidget(topWidget); QGridLayout *topLayout = new QGridLayout(this); topWidget->setLayout(topLayout); //------------------------- Parameters -------------------------- //Brightness QLabel *brightnessLabel = new QLabel(tr("Threshold:")); topLayout->addWidget(brightnessLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter); m_thresholdField = new DVGui::IntField(topWidget); m_thresholdField->setRange(0, 255); m_thresholdField->setValue(40); topLayout->addWidget(m_thresholdField, 0, 1); //Contrast QLabel *contrastLabel = new QLabel(tr("Softness:")); topLayout->addWidget(contrastLabel, 1, 0, Qt::AlignRight | Qt::AlignVCenter); m_softnessField = new DVGui::IntField(topWidget); m_softnessField->setRange(0, 100); m_softnessField->setValue(70); topLayout->addWidget(m_softnessField, 1, 1); topLayout->setRowStretch(2, 1); //--------------------------- Swatch ---------------------------- m_viewer = new Swatch(splitter); m_viewer->setMinimumHeight(150); m_viewer->setFocusPolicy(Qt::WheelFocus); splitter->addWidget(m_viewer); //--------------------------- Button ---------------------------- m_okBtn = new QPushButton(QString(tr("Apply")), this); connect(m_okBtn, SIGNAL(clicked()), this, SLOT(apply())); addButtonBarWidget(m_okBtn); //------------------------ Connections -------------------------- TApp *app = TApp::instance(); bool ret = true; ret = ret && connect(m_thresholdField, SIGNAL(valueChanged(bool)), this, SLOT(onValuesChanged(bool))); ret = ret && connect(m_softnessField, SIGNAL(valueChanged(bool)), this, SLOT(onValuesChanged(bool))); assert(ret); m_viewer->resize(0, 350); resize(600, 500); }
AdjustLevelsPopup::AdjustLevelsPopup() : DVGui::Dialog(TApp::instance()->getMainWindow(), true, false, "AdjustLevels"), m_thresholdD(0.005) //0.5% of the image size { int i, j; setWindowTitle(tr("Adjust Levels")); setLabelWidth(0); setModal(false); setTopMargin(0); setTopSpacing(0); beginVLayout(); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); addWidget(splitter); endVLayout(); //------------------------- Top Layout -------------------------- QScrollArea *scrollArea = new QScrollArea(splitter); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setWidgetResizable(true); scrollArea->setMinimumWidth(450); splitter->addWidget(scrollArea); splitter->setStretchFactor(0, 1); QFrame *topWidget = new QFrame(scrollArea); scrollArea->setWidget(topWidget); QVBoxLayout *topVLayout = new QVBoxLayout(topWidget); //Needed to justify at top topWidget->setLayout(topVLayout); QHBoxLayout *topLayout = new QHBoxLayout(topWidget); topVLayout->addLayout(topLayout); topVLayout->addStretch(1); //------------------------- Histogram --------------------------- m_histogram = new Histogram(topWidget); topLayout->addWidget(m_histogram); //------------------------- Mark Bars --------------------------- MarksBar *histogramMarksBar, *colorBarMarksBar; QVBoxLayout *histogramViewLayout; for (i = 0; i < 5; ++i) { HistogramView *view = m_histogram->getHistograms()->getHistogramView(i); histogramViewLayout = static_cast<QVBoxLayout *>(view->layout()); //Don't draw channel numbers view->channelBar()->setDrawNumbers(false); for (j = 0; j < 2; ++j) { EditableMarksBar *editableMarksBar = m_marksBar[j + (i << 1)] = new EditableMarksBar; MarksBar *marksBar = editableMarksBar->marksBar(); //Set margins up to cover the histogram editableMarksBar->layout()->setContentsMargins(6, 0, 5, 0); connect(editableMarksBar, SIGNAL(paramsChanged()), this, SLOT(onParamsChanged())); histogramViewLayout->insertWidget(1 + (j << 1), editableMarksBar); } } //------------------------- View Widget ------------------------- //NOTE: It's IMPORTANT that parent widget is supplied. It's somewhat //used by QSplitter to decide the initial widget sizes... m_viewer = new Swatch(splitter); m_viewer->setMinimumHeight(150); m_viewer->setFocusPolicy(Qt::WheelFocus); splitter->addWidget(m_viewer); //--------------------------- Buttons --------------------------- QVBoxLayout *buttonsLayout = new QVBoxLayout(topWidget); topLayout->addLayout(buttonsLayout); buttonsLayout->addSpacing(50); QPushButton *clampRange = new QPushButton(tr("Clamp"), topWidget); clampRange->setMinimumSize(65, 25); buttonsLayout->addWidget(clampRange); connect(clampRange, SIGNAL(clicked(bool)), this, SLOT(clampRange())); QPushButton *autoAdjust = new QPushButton(tr("Auto"), topWidget); autoAdjust->setMinimumSize(65, 25); buttonsLayout->addWidget(autoAdjust); connect(autoAdjust, SIGNAL(clicked(bool)), this, SLOT(autoAdjust())); QPushButton *resetBtn = new QPushButton(tr("Reset"), topWidget); resetBtn->setMinimumSize(65, 25); buttonsLayout->addWidget(resetBtn); connect(resetBtn, SIGNAL(clicked(bool)), this, SLOT(reset())); buttonsLayout->addStretch(1); m_okBtn = new QPushButton(tr("Apply")); addButtonBarWidget(m_okBtn); connect(m_okBtn, SIGNAL(clicked()), this, SLOT(apply())); //Finally, acquire current selection acquireRaster(); m_viewer->resize(0, 350); resize(600, 700); }
MeshifyPopup::MeshifyPopup() : DVGui::Dialog(TApp::instance()->getMainWindow(), true, false, "MeshifyPopup"), m_r(-1), m_c(-1) { setWindowTitle(tr("Create Mesh")); setLabelWidth(0); setModal(false); setTopMargin(0); setTopSpacing(0); beginVLayout(); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); addWidget(splitter); endVLayout(); //------------------------- Top Layout -------------------------- QScrollArea *scrollArea = new QScrollArea(splitter); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setWidgetResizable(true); scrollArea->setMinimumWidth(450); splitter->addWidget(scrollArea); splitter->setStretchFactor(0, 1); QFrame *topWidget = new QFrame(scrollArea); scrollArea->setWidget(topWidget); QGridLayout *topLayout = new QGridLayout(topWidget); // Needed to justify at top topWidget->setLayout(topLayout); //------------------------- Parameters -------------------------- int row = 0; QLabel *edgesLengthLabel = new QLabel(tr("Mesh Edges Length:")); topLayout->addWidget(edgesLengthLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); m_edgesLength = new DVGui::MeasuredDoubleField; m_edgesLength->setMeasure("length.x"); m_edgesLength->setRange(0.0, 1.0); // In inches (standard unit) m_edgesLength->setValue(0.2); topLayout->addWidget(m_edgesLength, row++, 1); QLabel *rasterizationDpiLabel = new QLabel(tr("Rasterization DPI:")); topLayout->addWidget(rasterizationDpiLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); m_rasterizationDpi = new DVGui::DoubleLineEdit; m_rasterizationDpi->setRange(1.0, (std::numeric_limits<double>::max)()); m_rasterizationDpi->setValue(300.0); topLayout->addWidget(m_rasterizationDpi, row++, 1); QLabel *shapeMarginLabel = new QLabel(tr("Mesh Margin (pixels):")); topLayout->addWidget(shapeMarginLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter); m_margin = new DVGui::IntLineEdit; m_margin->setRange(2, (std::numeric_limits<int>::max)()); m_margin->setValue(5); topLayout->addWidget(m_margin, row++, 1); connect(m_edgesLength, SIGNAL(valueChanged(bool)), this, SLOT(onParamsChanged(bool))); connect(m_rasterizationDpi, SIGNAL(editingFinished()), this, SLOT(onParamsChanged())); connect(m_margin, SIGNAL(editingFinished()), this, SLOT(onParamsChanged())); topLayout->setRowStretch(row, 1); //------------------------- View Widget ------------------------- // NOTE: It's IMPORTANT that parent widget is supplied. It's somewhat // used by QSplitter to decide the initial widget sizes... m_viewer = new Swatch(splitter); m_viewer->setMinimumHeight(150); m_viewer->setFocusPolicy(Qt::WheelFocus); splitter->addWidget(m_viewer); //--------------------------- Buttons --------------------------- m_okBtn = new QPushButton(tr("Apply")); addButtonBarWidget(m_okBtn); connect(m_okBtn, SIGNAL(clicked()), this, SLOT(apply())); // Finally, acquire current selection onCellSwitched(); m_viewer->resize(0, 350); resize(600, 700); }
BinarizePopup::BinarizePopup() : Dialog(TApp::instance()->getMainWindow(), true, false, "Binarize"), m_frameIndex(-1), m_progressBar(0), m_timerId(0) { setWindowTitle(tr("Binarize")); setLabelWidth(0); setModal(false); setTopMargin(0); setTopSpacing(0); beginVLayout(); QSplitter *splitter = new QSplitter(Qt::Vertical); splitter->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); addWidget(splitter); endVLayout(); QWidget *parametersArea = new QFrame(); splitter->addWidget(parametersArea); QGridLayout *parametersLayout = new QGridLayout(); // parametersArea->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); //QFrame* topWidget = new QFrame(scrollArea); //topWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); //scrollArea->setWidget(topWidget); // parametersLayout->setSizeConstraint(QLayout::SetFixedSize); //------------------------- Parameters -------------------------- /* //Brightness QLabel* brightnessLabel = new QLabel(tr("Brightness:")); topLayout->addWidget(brightnessLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter); m_brightnessField = new DVGui::IntField(topWidget); m_brightnessField->setRange(-127, 127); m_brightnessField->setValue(0); topLayout->addWidget(m_brightnessField, 0, 1); //Contrast QLabel* contrastLabel = new QLabel(tr("Contrast:")); topLayout->addWidget(contrastLabel, 1, 0, Qt::AlignRight | Qt::AlignVCenter); m_contrastField = new DVGui::IntField(topWidget); m_contrastField->setRange(-127, 127); m_contrastField->setValue(0); topLayout->addWidget(m_contrastField, 1, 1); */ m_alphaChk = new DVGui::CheckBox(tr("Alpha")); m_previewChk = new DVGui::CheckBox(tr("Preview")); parametersLayout->addWidget(m_alphaChk, 0, 0); parametersLayout->addWidget(m_previewChk, 0, 1); parametersArea->setLayout(parametersLayout); //--------------------------- Swatch ---------------------------- m_viewer = new Swatch(); m_viewer->setMinimumHeight(150); m_viewer->setFocusPolicy(Qt::WheelFocus); splitter->addWidget(m_viewer); splitter->setStretchFactor(0, 0); splitter->setStretchFactor(1, 1); //--------------------------- Button ---------------------------- m_okBtn = new QPushButton(tr("Apply"), this); connect(m_okBtn, SIGNAL(clicked()), this, SLOT(apply())); addButtonBarWidget(m_okBtn); //------------------------ Connections -------------------------- bool ret = true; //ret = ret && connect(m_brightnessField, SIGNAL(valueChanged(bool)), this, SLOT(onValuesChanged(bool))); //ret = ret && connect(m_contrastField, SIGNAL(valueChanged(bool)), this, SLOT(onValuesChanged(bool))); ret = ret && connect(m_previewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewCheckboxChanged(int))); ret = ret && connect(m_alphaChk, SIGNAL(stateChanged(int)), this, SLOT(onAlphaCheckboxChanged(int))); assert(ret); m_viewer->resize(0, 350); resize(600, 500); }