Ejemplo n.º 1
0
void Text3DOverlay::setProperties(const QVariantMap& properties) {
    Billboard3DOverlay::setProperties(properties);

    auto text = properties["text"];
    if (text.isValid()) {
        setText(text.toString());
    }

    auto textAlpha = properties["textAlpha"];
    if (textAlpha.isValid()) {
        float prevTextAlpha = getTextAlpha();
        setTextAlpha(textAlpha.toFloat());
        // Update our payload key if necessary to handle transparency
        if ((prevTextAlpha < 1.0f && _textAlpha >= 1.0f) || (prevTextAlpha >= 1.0f && _textAlpha < 1.0f)) {
            auto itemID = getRenderItemID();
            if (render::Item::isValidID(itemID)) {
                render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
                render::Transaction transaction;
                transaction.updateItem(itemID);
                scene->enqueueTransaction(transaction);
            }
        }
    }

    bool valid;
    auto backgroundColor = properties["backgroundColor"];
    if (backgroundColor.isValid()) {
        auto color = u8vec3FromVariant(backgroundColor, valid);
        if (valid) {
            _backgroundColor = color;
        }
    }

    if (properties["backgroundAlpha"].isValid()) {
        setAlpha(properties["backgroundAlpha"].toFloat());
    }

    if (properties["lineHeight"].isValid()) {
        setLineHeight(properties["lineHeight"].toFloat());
    }

    if (properties["leftMargin"].isValid()) {
        setLeftMargin(properties["leftMargin"].toFloat());
    }

    if (properties["topMargin"].isValid()) {
        setTopMargin(properties["topMargin"].toFloat());
    }

    if (properties["rightMargin"].isValid()) {
        setRightMargin(properties["rightMargin"].toFloat());
    }

    if (properties["bottomMargin"].isValid()) {
        setBottomMargin(properties["bottomMargin"].toFloat());
    }
}
Ejemplo n.º 2
0
void Text3DOverlay::setProperties(const QScriptValue& properties) {
    Planar3DOverlay::setProperties(properties);
    
    QScriptValue text = properties.property("text");
    if (text.isValid()) {
        setText(text.toVariant().toString());
    }

    QScriptValue backgroundColor = properties.property("backgroundColor");
    if (backgroundColor.isValid()) {
        QScriptValue red = backgroundColor.property("red");
        QScriptValue green = backgroundColor.property("green");
        QScriptValue blue = backgroundColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _backgroundColor.red = red.toVariant().toInt();
            _backgroundColor.green = green.toVariant().toInt();
            _backgroundColor.blue = blue.toVariant().toInt();
        }
    }

    if (properties.property("backgroundAlpha").isValid()) {
        _backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
    }

    if (properties.property("lineHeight").isValid()) {
        setLineHeight(properties.property("lineHeight").toVariant().toFloat());
    }

    if (properties.property("leftMargin").isValid()) {
        setLeftMargin(properties.property("leftMargin").toVariant().toFloat());
    }

    if (properties.property("topMargin").isValid()) {
        setTopMargin(properties.property("topMargin").toVariant().toFloat());
    }

    if (properties.property("rightMargin").isValid()) {
        setRightMargin(properties.property("rightMargin").toVariant().toFloat());
    }

    if (properties.property("bottomMargin").isValid()) {
        setBottomMargin(properties.property("bottomMargin").toVariant().toFloat());
    }

    QScriptValue isFacingAvatarValue = properties.property("isFacingAvatar");
    if (isFacingAvatarValue.isValid()) {
        _isFacingAvatar = isFacingAvatarValue.toVariant().toBool();
    }

}
Ejemplo n.º 3
0
void TextOverlay::setProperties(const QScriptValue& properties) {
    Overlay2D::setProperties(properties);
    _qmlElement->setX(_bounds.left());
    _qmlElement->setY(_bounds.top());
    _qmlElement->setWidth(_bounds.width());
    _qmlElement->setHeight(_bounds.height());
    _qmlElement->settextColor(toQmlColor(vec4(toGlm(_color), _alpha)));
    QScriptValue font = properties.property("font");
    if (font.isObject()) {
        if (font.property("size").isValid()) {
            setFontSize(font.property("size").toInt32());
        }
        QFont font(_qmlElement->fontFamily());
        font.setPixelSize(_qmlElement->fontSize());
        QFontMetrics fm(font);
        _qmlElement->setlineHeight(fm.lineSpacing() * 1.2);
    }

    QScriptValue text = properties.property("text");
    if (text.isValid()) {
        setText(text.toVariant().toString());
    }

    QScriptValue backgroundColor = properties.property("backgroundColor");
    if (backgroundColor.isValid()) {
        QScriptValue red = backgroundColor.property("red");
        QScriptValue green = backgroundColor.property("green");
        QScriptValue blue = backgroundColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _backgroundColor.red = red.toVariant().toInt();
            _backgroundColor.green = green.toVariant().toInt();
            _backgroundColor.blue = blue.toVariant().toInt();
        }
    }

    if (properties.property("backgroundAlpha").isValid()) {
        _backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
    }
    _qmlElement->setbackgroundColor(toQmlColor(vec4(toGlm(_backgroundColor), _backgroundAlpha)));

    if (properties.property("leftMargin").isValid()) {
        setLeftMargin(properties.property("leftMargin").toVariant().toInt());
    }

    if (properties.property("topMargin").isValid()) {
        setTopMargin(properties.property("topMargin").toVariant().toInt());
    }
}
Ejemplo n.º 4
0
KWidgetListbox::KWidgetListbox(QWidget *parent, const char *name)
 : QTable(parent, name)
{
  setNumRows(0);
  setNumCols(1);
  setColumnStretchable(0, true);
  setLeftMargin(0);
  setTopMargin(0);
  horizontalHeader()->hide();
  verticalHeader()->hide();
  setSelectionMode(QTable::NoSelection);
  setFocusStyle(QTable::FollowStyle);
  connect(this, SIGNAL(currentChanged(int, int)),
          this, SLOT(selectionChanged(int, int)));
  setHScrollBarMode(QScrollView::AlwaysOff);
  setVScrollBarMode(QScrollView::Auto);
}
int LineEditExtension::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = leftMargin(); break;
        case 1: *reinterpret_cast< int*>(_v) = rightMargin(); break;
        case 2: *reinterpret_cast< int*>(_v) = topMargin(); break;
        case 3: *reinterpret_cast< int*>(_v) = bottomMargin(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setLeftMargin(*reinterpret_cast< int*>(_v)); break;
        case 1: setRightMargin(*reinterpret_cast< int*>(_v)); break;
        case 2: setTopMargin(*reinterpret_cast< int*>(_v)); break;
        case 3: setBottomMargin(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 6
0
void QDeclarativeAnchors::setMargins(qreal offset)
{
    Q_D(QDeclarativeAnchors);
    if (d->margins == offset)
        return;
    //###Is it significantly faster to set them directly so we can call fillChanged only once?
    if(!d->rightMargin || d->rightMargin == d->margins)
        setRightMargin(offset);
    if(!d->leftMargin || d->leftMargin == d->margins)
        setLeftMargin(offset);
    if(!d->topMargin || d->topMargin == d->margins)
        setTopMargin(offset);
    if(!d->bottomMargin || d->bottomMargin == d->margins)
        setBottomMargin(offset);
    d->margins = offset;
    emit marginsChanged();

}
Ejemplo n.º 7
0
void TextOverlay::setProperties(const QScriptValue& properties) {
    Overlay2D::setProperties(properties);
    
    QScriptValue font = properties.property("font");
    if (font.isObject()) {
        if (font.property("size").isValid()) {
            setFontSize(font.property("size").toInt32());
        }
    }

    QScriptValue text = properties.property("text");
    if (text.isValid()) {
        setText(text.toVariant().toString());
    }

    QScriptValue backgroundColor = properties.property("backgroundColor");
    if (backgroundColor.isValid()) {
        QScriptValue red = backgroundColor.property("red");
        QScriptValue green = backgroundColor.property("green");
        QScriptValue blue = backgroundColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _backgroundColor.red = red.toVariant().toInt();
            _backgroundColor.green = green.toVariant().toInt();
            _backgroundColor.blue = blue.toVariant().toInt();
        }
    }

    if (properties.property("backgroundAlpha").isValid()) {
        _backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat();
    }

    if (properties.property("leftMargin").isValid()) {
        setLeftMargin(properties.property("leftMargin").toVariant().toInt());
    }

    if (properties.property("topMargin").isValid()) {
        setTopMargin(properties.property("topMargin").toVariant().toInt());
    }
}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
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);
}
Ejemplo n.º 10
0
bool QTable::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setNumRows((int)static_QUType_int.get(_o+1)); break;
    case 1: setNumCols((int)static_QUType_int.get(_o+1)); break;
    case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break;
    case 3: hideRow((int)static_QUType_int.get(_o+1)); break;
    case 4: hideColumn((int)static_QUType_int.get(_o+1)); break;
    case 5: showRow((int)static_QUType_int.get(_o+1)); break;
    case 6: showColumn((int)static_QUType_int.get(_o+1)); break;
    case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break;
    case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break;
    case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break;
    case 12: adjustRow((int)static_QUType_int.get(_o+1)); break;
    case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break;
    case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break;
    case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break;
    case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break;
    case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break;
    case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break;
    case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 26: clearSelection(); break;
    case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break;
    case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break;
    case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 34: static_QUType_bool.set(_o,dragEnabled()); break;
    case 35: insertRows((int)static_QUType_int.get(_o+1)); break;
    case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 37: insertColumns((int)static_QUType_int.get(_o+1)); break;
    case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 39: removeRow((int)static_QUType_int.get(_o+1)); break;
    case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 41: removeColumn((int)static_QUType_int.get(_o+1)); break;
    case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break;
    case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break;
    case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 51: columnClicked((int)static_QUType_int.get(_o+1)); break;
    case 52: doAutoScroll(); break;
    case 53: doValueChanged(); break;
    case 54: updateGeometriesSlot(); break;
    default:
	return QScrollView::qt_invoke( _id, _o );
    }
    return TRUE;
}
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);
}
Ejemplo n.º 12
0
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);
}