Exemplo n.º 1
0
TargetNodeSizeDlg::TargetNodeSizeDlg(QSizeF defaultSize, QWidget * parent)
: QDialog(parent)
, m_layout(new QGridLayout(this))
, m_okButton(new QPushButton(tr("Ok")))
, m_cancelButton(new QPushButton(tr("Cancel")))
, m_widthEdit(new QLineEdit)
, m_widthLabel(new QLabel(tr("Width:")))
, m_heightEdit(new QLineEdit)
, m_heightLabel(new QLabel(tr("Height:")))
{
    setWindowTitle(tr("Set target node size"));

    QIntValidator * widthValidator = new QIntValidator(this);
    widthValidator->setRange(TrackTile::TILE_W / 2, TrackTile::TILE_W * 4);
    m_widthEdit->setValidator(widthValidator);
    m_widthEdit->setText(QString("%1").arg(defaultSize.width()));

    QIntValidator * heightValidator = new QIntValidator(this);
    heightValidator->setRange(TrackTile::TILE_H / 2, TrackTile::TILE_H * 4);
    m_heightEdit->setValidator(widthValidator);
    m_heightEdit->setText(QString("%1").arg(defaultSize.height()));

    m_layout->addWidget(m_widthLabel,   0, 0);
    m_layout->addWidget(m_widthEdit,    0, 1);
    m_layout->addWidget(m_heightLabel,  1, 0);
    m_layout->addWidget(m_heightEdit,   1, 1);
    m_layout->addWidget(m_okButton,     3, 0);
    m_layout->addWidget(m_cancelButton, 3, 1);

    connect(m_okButton, &QPushButton::clicked, this, &TargetNodeSizeDlg::accept);
    connect(m_cancelButton, &QPushButton::clicked, this, &TargetNodeSizeDlg::reject);
}
Exemplo n.º 2
0
QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_int(_argument->range_start));

        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
            textValidator->setBottom(0);

        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_int(_argument->range_end));
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(defaultValue());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
Exemplo n.º 3
0
static QLineEdit *addIntEdit(const QString &default_value, QWidget *parent) {
  QIntValidator *v = new QIntValidator(parent);
  v->setBottom(0);
  QLineEdit *e = new QLineEdit(default_value, parent);
  e->setValidator(v);
  return e;
}
Exemplo n.º 4
0
AddUnitDialog::AddUnitDialog(QWidget* Parent):
  openfluid::ui::common::MessageDialog(Parent),ui(new Ui::AddUnitDialog)
{
  ui->setupUi(this);

  setupMessageUi("");

  QIntValidator* IDValidator = new QIntValidator(this);
  IDValidator->setBottom(0);

  ui->UnitIDEdit->setValidator(IDValidator);

  ui->UnitIDEdit->setPlaceholderText(getPlaceholderRequired());
}
Exemplo n.º 5
0
TimelinePage::TimelinePage(QWidget* parent) : QWidget(parent)
{
    QSettings settings( PENCIL2D, PENCIL2D );

    QVBoxLayout* lay = new QVBoxLayout();

    QGroupBox* timeLineBox = new QGroupBox(tr("Timeline"));
    mDrawLabel = new QCheckBox(tr("Draw timeline labels"));
    mFontSize = new QSpinBox();
    QLabel* frameSizeLabel = new QLabel(tr("Frame size"));
    mFrameSize = new QSlider(Qt::Horizontal, this);
    QLabel* lengthSizeLabel = new QLabel(tr("Timeline size in Frames"));
    mLengthSize = new QLineEdit(this);
    QIntValidator* lengthSizeValidator = new QIntValidator(this);
    lengthSizeValidator->setBottom(2);
    mLengthSize->setValidator( lengthSizeValidator );

    mScrubBox = new QCheckBox(tr("Short scrub"));

    mFontSize->setRange(4, 20);
    mFrameSize->setRange(4, 20);

    mFontSize->setFixedWidth(50);
    mLengthSize->setFixedWidth(50);


    mFrameSize->setValue(settings.value("frameSize").toInt());
    if (settings.value("labelFontSize").toInt()==0) mFontSize->setValue(12);
    if (settings.value("frameSize").toInt()==0) mFrameSize->setValue(6);
    mLengthSize->setText(settings.value("length").toString());
    if (settings.value("length").toInt()==0) mLengthSize->setText("240");

    connect(mFontSize, SIGNAL(valueChanged(int)), this, SLOT(fontSizeChange(int)));
    connect(mFrameSize, SIGNAL(valueChanged(int)), this, SLOT(frameSizeChange(int)));
    connect(mLengthSize, SIGNAL(textChanged(QString)), this, SLOT(lengthSizeChange(QString)));
    connect( mDrawLabel, &QCheckBox::stateChanged, this, &TimelinePage::labelChange );
    connect( mScrubBox, &QCheckBox::stateChanged, this, &TimelinePage::scrubChange );

    lay->addWidget(frameSizeLabel);
    lay->addWidget(mFrameSize);
    lay->addWidget(lengthSizeLabel);
    lay->addWidget(mLengthSize);
    lay->addWidget(mScrubBox);
    timeLineBox->setLayout(lay);

    QVBoxLayout* lay2 = new QVBoxLayout();
    lay2->addWidget(timeLineBox);
    lay2->addStretch(1);
    setLayout(lay2);
}
Exemplo n.º 6
0
QString BaseName(QString pName)
{
    if (pName == "") return "";

    QStringList parts = pName.split("_");
    if (parts.size() == 1) return pName;

    int pos;
    QString last = parts.last();
    QIntValidator intValidator;
    if (intValidator.validate(last, pos) != QValidator::Invalid)
        return pName.left(pName.size() - last.size() - 1);

    return pName;
}
Exemplo n.º 7
0
  /**
   * Attaches this tool to the toolbar
   *
   * @param parent
   *
   * @return QWidget*
   */
  QWidget *StatisticsTool::createToolBarWidget(QStackedWidget *parent) {
    QWidget *hbox = new QWidget(parent);

    QIntValidator *ival = new QIntValidator(hbox);
    ival->setRange(1, 100);

    QLabel *sampleLabel = new QLabel("Box Samples:");
    p_sampsEdit = new QLineEdit(hbox);
    p_sampsEdit->setValidator(ival);
    p_sampsEdit->setMaximumWidth(50);

    QString samps;
    samps.setNum(p_boxSamps);

    p_sampsEdit->setText(samps);
    connect(p_sampsEdit, SIGNAL(editingFinished()), this, SLOT(changeBoxSamples()));

    QLabel *lineLabel = new QLabel("Box Lines:");
    p_linesEdit = new QLineEdit(hbox);
    p_linesEdit->setValidator(ival);
    p_linesEdit->setMaximumWidth(50);

    QString lines;
    lines.setNum(p_boxLines);

    p_linesEdit->setText(lines);
    connect(p_linesEdit, SIGNAL(editingFinished()), this, SLOT(changeBoxLines()));

    QToolButton *showButton = new QToolButton();
    showButton->setText("Show");
    showButton->setToolTip("");
    QString text = "";
    showButton->setWhatsThis(text);

    connect(showButton, SIGNAL(clicked()), p_dialog, SLOT(show()));

    QHBoxLayout *layout = new QHBoxLayout;
    layout->setMargin(0);
    layout->addWidget(sampleLabel);
    layout->addWidget(p_sampsEdit);
    layout->addWidget(lineLabel);
    layout->addWidget(p_linesEdit);
    layout->addWidget(showButton);
    layout->addStretch(1);
    hbox->setLayout(layout);
    return hbox;
  }
Exemplo n.º 8
0
void ICParameterRange::UpdateConfigRangeValidator(uint type, double min, double max)
{
    if(!configsRangeCache_.contains(type)) return;
    QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(type));
    if(dv != NULL)
    {
        dv->setBottom(min);
        dv->setTop(max);
        return;
    }
    QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(type));
    if(iv != NULL)
    {
        iv->setBottom(min);
        iv->setTop(max);
    }
}
Exemplo n.º 9
0
MainWindow::MainWindow(QWidget *parent)
    :QWidget(parent), _ui(new Ui::MainWindow), _currentMode(NormalMode)
{
    _ui->setupUi(this);

    QIntValidator *validator = new QIntValidator(this);
    validator->setBottom(0);
    _ui->spendLineEdit->setValidator(validator);
    _ui->dateDateEdit->setDisplayFormat(ExpenseBook::dateFormat());
    _ui->dateDateEdit->setCalendarPopup(true);

    connect(_ui->addExpensePushButton, SIGNAL(clicked()), this, SLOT(_onAddExpenseButtonClicked()));
    connect(_ui->expenseListView, SIGNAL(clicked(QModelIndex)), this, SLOT(_onExpenseListItemSelected(QModelIndex)));
    connect(_ui->changeDatabasePathPushButton, SIGNAL(clicked()), this, SLOT(_onChangeDatabasePathButtonClicked()));
    connect(_ui->savePushButton, SIGNAL(clicked()), this, SLOT(_onSaveButtonClicked()));
    connect(_ui->deletePushButton, SIGNAL(clicked()), SLOT(_onDeleteButtonClicked()));
}
static PyObject *meth_QIntValidator_validate(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;
    bool sipSelfWasArg = (!sipSelf || sipIsDerived((sipSimpleWrapper *)sipSelf));

    if (sipIsAPIEnabled(sipName_QString, 2, 0))
    {
        QString * a0;
        int a0State = 0;
        int a1;
        QIntValidator *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1i", &sipSelf, sipType_QIntValidator, &sipCpp, sipType_QString,&a0, &a0State, &a1))
        {
            QValidator::State sipRes;
            PyObject *sipResult;

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp->QIntValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1));
            Py_END_ALLOW_THREADS

            sipResult = sipBuildResult(0,"(FDi)",sipRes,sipType_QValidator_State,a0,sipType_QString,NULL,a1);
            sipReleaseType(a0,sipType_QString,a0State);

            return sipResult;
        }
    }

    if (sipIsAPIEnabled(sipName_QString, 0, 2))
    {
        QString * a0;
        int a1;
        QIntValidator *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9i", &sipSelf, sipType_QIntValidator, &sipCpp, sipType_QString,&a0, &a1))
        {
            QValidator::State sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = (sipSelfWasArg ? sipCpp->QIntValidator::validate(*a0,a1) : sipCpp->validate(*a0,a1));
            Py_END_ALLOW_THREADS

            return sipBuildResult(0,"(Fi)",sipRes,sipType_QValidator_State,a1);
        }
Exemplo n.º 11
0
QCntEditForm::QCntEditForm(QWidget *parent,QPattern *data) :
    QWidget(parent),pattern(data){
    setupUi(this);
    ///////////////////////////
    setFixedSize(800,600);
    setWindowFlags(Qt::FramelessWindowHint);
    pcheckBoxArray1[0]=pushButton_01;
    pcheckBoxArray1[1]=pushButton_02;
    pcheckBoxArray1[2]=pushButton_03;
    pcheckBoxArray1[3]=pushButton_04;
    pcheckBoxArray1[4]=pushButton_05;
    pcheckBoxArray1[5]=pushButton_06;
    pcheckBoxArray1[6]=pushButton_07;
    pcheckBoxArray1[7]=pushButton_08;

    pcheckBoxArray2[0]=pushButton_11;
    pcheckBoxArray2[1]=pushButton_12;
    pcheckBoxArray2[2]=pushButton_13;
    pcheckBoxArray2[3]=pushButton_14;
    pcheckBoxArray2[4]=pushButton_15;
    pcheckBoxArray2[5]=pushButton_16;
    pcheckBoxArray2[6]=pushButton_17;
    pcheckBoxArray2[7]=pushButton_18;
    QIntValidator *intval = new QIntValidator(this);
    intval->setRange(1,pattern->tatalcntrow);
    lineEdit_row->setValidator(intval);
    lineEdit_row->setText("1");
    rowToggle(1);
    label_totalrow->setNum(pattern->tatalcntrow);

    for(unsigned int i=0;;i++){
        QStringList list = QPattern::cnt_ZhilingStringlist(i);
        if(list.isEmpty())
            break;
        QString str =list.join(" , ");
        comboBox_zllh->addItem(str);
        comboBox_zllq->addItem(str);
        comboBox_zlrh->addItem(str);
        comboBox_zlrq->addItem(str);
    }
    ////////////////////////////
}
Exemplo n.º 12
0
void ICParameterRange::UpdateConfigRangeValidator(const ICAddrWrapper *addr, double value)
{
//    QMap<const ICAddrWrapper*, uint>::iterator p = addrToMaxValidator_.find(addr);
    value /= qPow(10, addr->Decimal());
    QList<uint> vs = addrToMaxValidator_.values(addr);
    for(int i = 0; i != vs.size(); ++i)
    {
        if(!configsRangeCache_.contains(vs.at(i))) continue;
        QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
        if(dv != NULL)
        {
            dv->setTop(value);
//            ++p;
            continue;
        }
        QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
        if(iv != NULL)
        {
            iv->setTop(value);
        }
    }

    vs  = addrToMinValidator_.values(addr);
    for(int i = 0; i != vs.size(); ++i)
    {
        if(!configsRangeCache_.contains(vs.at(i))) continue;
        QDoubleValidator* dv = static_cast<QDoubleValidator*>(configsRangeCache_.value(vs.at(i)));
        if(dv != NULL)
        {
            dv->setBottom(value);
//            ++p;
            continue;
        }
        QIntValidator* iv = static_cast<QIntValidator*>(configsRangeCache_.value(vs.at(i)));
        if(iv != NULL)
        {
            iv->setBottom(value);
        }
    }

}
void DigDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex& index) const {
    QLineEdit *le = qobject_cast<QLineEdit*>(editor);
    QString value = le->text();
    int pos = 0;

    if (m_type == "DBL") {
        QDoubleValidator *dv = new QDoubleValidator(le);
        QValidator::State state = dv->validate(value,pos);
        if (state != QValidator::Acceptable) {
            return;
        }
    }
    if (m_type == "INT") {
        QIntValidator *iv = new QIntValidator(le);
        QValidator::State state = iv->validate(value,pos);
        if (state != QValidator::Acceptable) {
            return;
        }
    }
    model->setData(index, value);
}
Exemplo n.º 14
0
DMXSlider::DMXSlider(QWidget* parent)
    : QWidget(parent)
    , m_edit(NULL)
    , m_slider(NULL)
    , m_label(NULL)
{
    new QVBoxLayout(this);
    layout()->setSpacing(1);
    layout()->setContentsMargins(1, 1, 1, 1);

    /* Value editor */
    m_edit = new QLineEdit(this);
    m_edit->setMaxLength(3);
    m_edit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    m_edit->setAlignment(Qt::AlignHCenter);
    QIntValidator* validator = new QIntValidator(m_edit);
    validator->setRange(0, UCHAR_MAX);
    m_edit->setValidator(validator);
    layout()->addWidget(m_edit);
    layout()->setAlignment(m_edit, Qt::AlignHCenter);
    connect(m_edit, SIGNAL(textEdited(QString)), this, SLOT(slotValueEdited(QString)));

    /* Value slider */
    m_slider = new QSlider(this);
    m_slider->setRange(0, UCHAR_MAX);
    m_slider->setTickInterval(16);
    m_slider->setTickPosition(QSlider::TicksBothSides);
    m_slider->setStyle(AppUtil::saneStyle());
    layout()->addWidget(m_slider);
    layout()->setAlignment(m_slider, Qt::AlignRight);
    connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderChanged(int)));

    /* Label */
    m_label = new QLabel(this);
    m_label->setWordWrap(true);
    layout()->addWidget(m_label);
    layout()->setAlignment(m_label, Qt::AlignHCenter);

    slotSliderChanged(0);
}
Exemplo n.º 15
0
DialogClient::DialogClient(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogClient)
{
    ui->setupUi(this);

    //端口验证
    QIntValidator *vali = new QIntValidator();
    vali->setRange(0, 65535);
    ui->lineEditPort->setValidator(vali);
    //
    ui->lineEditPort->setText("2000");
    ui->lineEditIP->setText("127.0.0.1");

    this->setLayout(ui->mainLayout);

    //创建客户端
    m_pTCPClient = new QTcpSocket();
    //关联信号
    connect(m_pTCPClient, SIGNAL(connected()), this, SLOT(OnSuccConnect()));
    connect(m_pTCPClient, SIGNAL(readyRead()), this, SLOT(ReadStructDataAndShow()));
}
Exemplo n.º 16
0
void SliderSettingsDialog::init()
{
  mpSlider = NULL;
  mChanged = NONE;
  mScaling = CSlider::linear;
  mpObjectBrowseButton->setIcon(CQIconResource::icon(CQIconResource::copasi));
  mpExtendedOptionsButton->setText("Advanced >>");
  hideOptionsControls();
  this->setFixedSize(minimumSizeHint());
  mpObjectValueEdit->setValidator(new QDoubleValidator(this));
  mpOriginalValueEdit->setValidator(new QDoubleValidator(this));
  mpMinValueEdit->setValidator(new QDoubleValidator(this));
  mpMaxValueEdit->setValidator(new QDoubleValidator(this));
  mpMinorTickSizeEdit->setValidator(new QDoubleValidator(this));
  QIntValidator* v = new QIntValidator(this);
  v->setBottom(0);
  mpNumMinorTicksEdit->setValidator(v);
  v = new QIntValidator(this);
  v->setBottom(0);
  mpMinorMajorFactorEdit->setValidator(v);
  updateInputFields();
}
Exemplo n.º 17
0
QComboBox * TraceWire::createWidthComboBox(double m, QWidget * parent) 
{
	QComboBox * comboBox = new FocusOutComboBox(parent);  // new QComboBox(parent);
	comboBox->setEditable(true);
	QIntValidator * intValidator = new QIntValidator(comboBox);
	intValidator->setRange(MinTraceWidthMils, MaxTraceWidthMils);
	comboBox->setValidator(intValidator);

	int ix = 0;
	if (!Wire::widths.contains(m)) {
		Wire::widths.append(m);
		qSort(Wire::widths.begin(), Wire::widths.end());
	}
	foreach(long widthValue, Wire::widths) {
		QString widthName = Wire::widthTrans.value(widthValue, "");
		QVariant val((int) widthValue);
		comboBox->addItem(widthName.isEmpty() ? QString::number(widthValue) : widthName, val);
		if (qAbs(m - widthValue) < .01) {
			comboBox->setCurrentIndex(ix);
		}
		ix++;
	}
Exemplo n.º 18
0
GetPlayerCountDialog::GetPlayerCountDialog (QWidget* parent)
    : QDialog (parent)
{
    QIntValidator validator;
    validator.setBottom (3);
    validator.setTop (32);

    lineEdit = new QLineEdit (NULL);
    pushButton = new QPushButton ("OK", NULL);
    pushButton->setAutoDefault (true);
    QString string("16");
    lineEdit->setText (string);
    lineEdit->setAlignment (Qt::AlignVCenter | Qt::AlignHCenter);
    lineEdit->setGeometry (0, 0, 180, 75);
    lineEdit->setValidator (&validator);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget (lineEdit);
    mainLayout->addWidget (pushButton);
    setLayout (mainLayout);

    connect (pushButton, SIGNAL (clicked ()), this, SLOT (accept ()));
}
Exemplo n.º 19
0
NewRoomWindow::NewRoomWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::NewRoomWindow)
{
    ui->setupUi(this);
    // set validator for two lineinputs
    QIntValidator *inva = new QIntValidator(this);
    // 4860*4860 = 220MB for each layer
    // 10 layers will cost about 2200MB, which is 2GB.
    inva->setRange(1, 4860);
    ui->height_input->setValidator(inva);
    ui->width_input->setValidator(inva);
    ui->buttonBox->
            button(QDialogButtonBox::Ok)->setEnabled(false);
    connect(ui->lineEdit, &QLineEdit::textChanged,
            this, &NewRoomWindow::onNameChanged);
    connect(ui->buttonBox->button(QDialogButtonBox::Ok),
            &QPushButton::clicked,
            this, &NewRoomWindow::onOk);
    connect(ui->buttonBox->button(QDialogButtonBox::Cancel),
            &QPushButton::clicked,
            this, &NewRoomWindow::onCancel);
}
Exemplo n.º 20
0
void Advanced::prepareUi()
{
    Selection *s = new Selection(this);

    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openRaster()));
    connect(ui->actionSave_Reprojection, SIGNAL(triggered()), this, SLOT(saveReprojection()));
    connect(ui->actionSelection_Screen, SIGNAL(triggered()), s, SLOT(showSelection()));
    connect(ui->actionSelection_Screen, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionLoad_Projection_Info, SIGNAL(triggered()), this, SLOT(loadParams()));
    connect(ui->actionSave_Projection_Info, SIGNAL(triggered()), this, SLOT(saveParams()));
    connect(ui->actionToggle_Preview, SIGNAL(triggered()), this, SLOT(togglePreview()));
    connect(ui->actionAbout_dRasterBlaster, SIGNAL(triggered()), s, SLOT(about()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), s, SLOT(aboutQt()));
    connect(ui->actionEdit_Author, SIGNAL(triggered()), s, SLOT(showEditAuthor()));
    connect(ui->actionUser_Guide, SIGNAL(triggered()), s, SLOT(showUserGuide()));
    connect(ui->fillEnable, SIGNAL(stateChanged(int)), this, SLOT(fillEnable(int)));
    connect(ui->noDataValueEnable, SIGNAL(stateChanged(int)), this, SLOT(noDataEnable(int)));

    //Validators
    QIntValidator *intValid = new QIntValidator(this);
    intValid->setBottom(0);

    QDoubleValidator *doubleValid = new QDoubleValidator(this);
    doubleValid->setNotation(QDoubleValidator::StandardNotation);
    doubleValid->setBottom(0.0);

    ui->Rows->setValidator(intValid);
    ui->Cols->setValidator(intValid);
    ui->FillValue->setValidator(intValid);
    ui->noDataValue->setValidator(intValid);
    ui->pixelSize->setValidator(doubleValid);

    //projections p;
    //p.callGenerate(_UTM);
    //ui->tabProjectionInfo->setLayout(p.projVLayout);
}
Exemplo n.º 21
0
QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    QString storeValue;
    QString text = defaultValue();

    if ( _argument->storeval )
    {
        QString storeValue = _argument->storeval;

        if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
            text = storeValue;
    }

    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_start);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_start);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_start of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setBottom(val);
        }
        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
        {
            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "%s sets negative bottom range for unsigned value, setting to 0", _argument->call );
            textValidator->setBottom(0);
        }

        if ( _argument->range_end != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_end);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_end);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_end of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setTop(val);
        }
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(text.trimmed());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
Exemplo n.º 22
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
        ui->setupUi(this);

        thread = new QThread();
        worker = new Worker();

        worker->moveToThread(thread);
        connect(worker, SIGNAL(workRequested()), thread, SLOT(start()));
        connect(thread, SIGNAL(started()), worker, SLOT(doWork()));
        connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);

        Architecturelistfull << "Linear"
                             << "Star"
                             << "Network"
                             << "Dangling";
        Flowlistfull << "Inception of Shear"
                   //<< "Step Shear"
                     << "Uniaxial Elongation"
                     << "Biaxial Elongation"
                     << "Planar Elongation"
                   //<< "Step Elongation"
                     << "Custom"  ;
        //def row

        //Architecture Tab
//        int last_row = ui->tableWidget_2->rowCount();
//        ui->tableWidget_2->insertRow(0);
//        QPointer<QCheckBox> Delete = new QCheckBox(this);
//        QPointer<QComboBox> Architecture = new QComboBox(this);
//        Architecture->addItems(Architecturelistfull);
//        for (int i=1; i<Architecture->count();++i)
//            Architecture->setItemData(i,"DISABLE",Qt::UserRole-1); //disable architectures other than linear

//        ui->tableWidget_2->setCellWidget(last_row,0,Delete);
//        ui->tableWidget_2->setCellWidget(last_row,2,Architecture);
//        Architecturelist.append(Architecture);
//        Deletelist.append(Delete);

        ui->label_15->setText(QString::fromUtf8("\u2207v:"));
        //ui->combo_chemistry_probe->setItemData(5,"DISABLE",Qt::UserRole-1); //disable custom parameters option

        for (int i=1; i<ui->combo_arch_probe->count();++i)
            ui->combo_arch_probe->setItemData(i,"DISABLE",Qt::UserRole-1); //disable architectures other than linear

        ui->checkBox_9->setEnabled(false);

        validator = new QDoubleValidator();
        validator->setBottom(0);
        QDoubleValidator* validator2 = new QDoubleValidator();
        QIntValidator* validatorInt = new QIntValidator();
        validatorInt->setBottom(0);
        ui->lineEdit_4->setValidator(validator);
        ui->lineEdit_3->setValidator(validator);
        ui->edit_beta_FSM->setValidator(validator);
        ui->edit_mw_probe->setValidator(validator);
        ui->edit_rate->setValidator(validator);
        ui->lineEdit_11->setValidator(validator2);
        ui->lineEdit_12->setValidator(validator2);
        ui->lineEdit_14->setValidator(validator2);
        ui->lineEdit_15->setValidator(validator2);
        ui->lineEdit_16->setValidator(validator2);
        ui->lineEdit_17->setValidator(validator2);
        ui->lineEdit_18->setValidator(validator2);
        ui->lineEdit_19->setValidator(validator2);
        ui->lineEdit_20->setValidator(validator2);
        ui->edit_strain->setValidator(validator);
        ui->edit_n_cha->setValidator(validatorInt);

        ui->Wi->setReadOnly(true);
        ui->progressBar_1->setVisible(false);
        ui->progressBar_2->setVisible(false);

        ui->label_19->setText(QString::fromUtf8("Simulation time / \u03C4<sub>k</sub> :"));
        //loading saved settings
        exec_path = QCoreApplication::applicationDirPath();
        def_setting.prepend(exec_path);
        flow_setting.prepend(exec_path);
        chemistry_setting.prepend(exec_path);

        load_settings(def_setting);
    }
Exemplo n.º 23
0
TLMCoSimulationDialog::TLMCoSimulationDialog(MainWindow *pMainWindow)
  : QDialog(pMainWindow)
{
  resize(450, 350);
  mpMainWindow = pMainWindow;
  setIsTLMCoSimulationRunning(false);
  // simulation widget heading
  mpHeadingLabel = Utilities::getHeadingLabel("");
  mpHeadingLabel->setElideMode(Qt::ElideMiddle);
  // Horizontal separator
  mpHorizontalLine = Utilities::getHeadingLine();
  // TLM Plugin Path
  mpTLMPluginPathLabel = new Label(tr("TLM Plugin Path:"));
  mpTLMPluginPathTextBox = new QLineEdit;
  mpBrowseTLMPluginPathButton = new QPushButton(Helper::browse);
  mpBrowseTLMPluginPathButton->setAutoDefault(false);
  connect(mpBrowseTLMPluginPathButton, SIGNAL(clicked()), SLOT(browseTLMPluginPath()));
  // tlm manager groupbox
  mpTLMManagerGroupBox = new QGroupBox(tr("TLM Manager"));
  // TLM Manager Process
  mpManagerProcessLabel = new Label(tr("Manager Process:"));
  mpManagerProcessTextBox = new QLineEdit;
  mpBrowseManagerProcessButton = new QPushButton(Helper::browse);
  mpBrowseManagerProcessButton->setAutoDefault(false);
  connect(mpBrowseManagerProcessButton, SIGNAL(clicked()), SLOT(browseManagerProcess()));
  // TLM Monitor Process
  mpMonitorProcessLabel = new Label(tr("Monitor Process:"));
  mpMonitorProcessTextBox = new QLineEdit;
  mpBrowseMonitorProcessButton = new QPushButton(Helper::browse);
  mpBrowseMonitorProcessButton->setAutoDefault(false);
  connect(mpBrowseMonitorProcessButton, SIGNAL(clicked()), SLOT(browseMonitorProcess()));
  // manager server port
  mpServerPortLabel = new Label(tr("Server Port:"));
  mpServerPortLabel->setToolTip(tr("Set the server network port for communication with the simulation tools"));
  mpServerPortTextBox = new QLineEdit("11111");
  // manager monitor port
  mpMonitorPortLabel = new Label(tr("Monitor Port:"));
  mpMonitorPortLabel->setToolTip(tr("Set the port for monitoring connections"));
  mpMonitorPortTextBox = new QLineEdit("12111");
  // tlm manager debug mode
  mpManagerDebugModeCheckBox = new QCheckBox(tr("Debug Mode"));
  // tlm manager layout
  QGridLayout *pTLMManagerGridLayout = new QGridLayout;
  pTLMManagerGridLayout->addWidget(mpManagerProcessLabel, 0, 0);
  pTLMManagerGridLayout->addWidget(mpManagerProcessTextBox, 0, 1);
  pTLMManagerGridLayout->addWidget(mpBrowseManagerProcessButton, 0, 2);
  pTLMManagerGridLayout->addWidget(mpServerPortLabel, 1, 0);
  pTLMManagerGridLayout->addWidget(mpServerPortTextBox, 1, 1, 1, 2);
  pTLMManagerGridLayout->addWidget(mpMonitorPortLabel, 2, 0);
  pTLMManagerGridLayout->addWidget(mpMonitorPortTextBox, 2, 1, 1, 2);
  pTLMManagerGridLayout->addWidget(mpManagerDebugModeCheckBox, 3, 0, 1, 3);
  mpTLMManagerGroupBox->setLayout(pTLMManagerGridLayout);
  // tlm monitor groupBox
  mpTLMMonitorGroupBox = new QGroupBox(tr("TLM Monitor"));
  // number of steps
  mpNumberOfStepsLabel = new Label(tr("Number Of Steps:"));
  mpNumberOfStepsTextBox = new QLineEdit;
  // time step size
  mpTimeStepSizeLabel = new Label(tr("Time Step Size:"));
  mpTimeStepSizeTextBox = new QLineEdit;
  // tlm monitor debug mode
  mpMonitorDebugModeCheckBox = new QCheckBox(tr("Debug Mode"));
  // tlm monitor layout
  QGridLayout *pTLMMonitorGridLayout = new QGridLayout;
  pTLMMonitorGridLayout->addWidget(mpMonitorProcessLabel, 0, 0);
  pTLMMonitorGridLayout->addWidget(mpMonitorProcessTextBox, 0, 1);
  pTLMMonitorGridLayout->addWidget(mpBrowseMonitorProcessButton, 0, 2);
  pTLMMonitorGridLayout->addWidget(mpNumberOfStepsLabel, 1, 0);
  pTLMMonitorGridLayout->addWidget(mpNumberOfStepsTextBox, 1, 1, 1, 2);
  pTLMMonitorGridLayout->addWidget(mpTimeStepSizeLabel, 2, 0);
  pTLMMonitorGridLayout->addWidget(mpTimeStepSizeTextBox, 2, 1, 1, 2);
  pTLMMonitorGridLayout->addWidget(mpMonitorDebugModeCheckBox, 3, 0, 1, 3);
  mpTLMMonitorGroupBox->setLayout(pTLMMonitorGridLayout);
  // Create the buttons
  // show TLM Co-simulation output window button
  mpShowTLMCoSimulationOutputWindowButton = new QPushButton(tr("Show TLM Co-Simulation Output Window"));
  mpShowTLMCoSimulationOutputWindowButton->setAutoDefault(false);
  connect(mpShowTLMCoSimulationOutputWindowButton, SIGNAL(clicked()), this, SLOT(showTLMCoSimulationOutputWindow()));
  // run TLM co-simulation button.
  mpRunButton = new QPushButton(Helper::simulate);
  mpRunButton->setAutoDefault(true);
  connect(mpRunButton, SIGNAL(clicked()), this, SLOT(runTLMCoSimulation()));
  // cancel TLM co-simulation dialog button.
  mpCancelButton = new QPushButton(Helper::cancel);
  mpCancelButton->setAutoDefault(false);
  connect(mpCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
  // adds buttons to the button box
  mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
  mpButtonBox->addButton(mpRunButton, QDialogButtonBox::ActionRole);
  mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
  // validators
  QIntValidator *pIntegerValidator = new QIntValidator(this);
  pIntegerValidator->setBottom(0);
  mpServerPortTextBox->setValidator(pIntegerValidator);
  mpMonitorPortTextBox->setValidator(pIntegerValidator);
  mpNumberOfStepsTextBox->setValidator(pIntegerValidator);
  QDoubleValidator *pDoubleValidator = new QDoubleValidator(this);
  pDoubleValidator->setBottom(0);
  mpTimeStepSizeTextBox->setValidator(pDoubleValidator);
  // layout
  QGridLayout *pMainLayout = new QGridLayout;
  pMainLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
  pMainLayout->addWidget(mpHeadingLabel, 0, 0, 1, 3);
  pMainLayout->addWidget(mpHorizontalLine, 1, 0, 1, 3);
  pMainLayout->addWidget(mpTLMPluginPathLabel, 2, 0);
  pMainLayout->addWidget(mpTLMPluginPathTextBox, 2, 1);
  pMainLayout->addWidget(mpBrowseTLMPluginPathButton, 2, 2);
  pMainLayout->addWidget(mpTLMManagerGroupBox, 3, 0, 1, 3);
  pMainLayout->addWidget(mpTLMMonitorGroupBox, 4, 0, 1, 3);
  pMainLayout->addWidget(mpShowTLMCoSimulationOutputWindowButton, 5, 0, 1, 3);
  pMainLayout->addWidget(mpButtonBox, 6, 0, 1, 3, Qt::AlignRight);
  setLayout(pMainLayout);
  // create TLMCoSimulationOutputWidget
  mpTLMCoSimulationOutputWidget = new TLMCoSimulationOutputWidget(mpMainWindow);
  int xPos = QApplication::desktop()->availableGeometry().width() - mpTLMCoSimulationOutputWidget->frameSize().width() - 20;
  int yPos = QApplication::desktop()->availableGeometry().height() - mpTLMCoSimulationOutputWidget->frameSize().height() - 20;
  mpTLMCoSimulationOutputWidget->setGeometry(xPos, yPos, mpTLMCoSimulationOutputWidget->width(), mpTLMCoSimulationOutputWidget->height());
}
Exemplo n.º 24
0
void DefaultGUIModel::createGUI(DefaultGUIModel::variable_t *var, int size) {

	// Make Mdi
	subWindow = new QMdiSubWindow;
	subWindow->setWindowIcon(QIcon("/usr/local/lib/rtxi/RTXI-widget-icon.png"));
	MainWindow::getInstance()->createMdi(subWindow);

	// Create main layout
	layout = new QGridLayout;

	// Create child widget and gridLayout
	gridBox = new QGroupBox;
	QGridLayout *gridLayout = new QGridLayout;

	size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
	for (uint16_t i = 0; i < size; i++) {
		if (var[i].flags & (PARAMETER | STATE | EVENT | COMMENT)) {
			param_t param;

			param.label = new QLabel(QString::fromStdString(var[i].name), gridBox);
			gridLayout->addWidget(param.label, parameter.size(), 0);
			param.edit = new DefaultGUILineEdit(gridBox);
			gridLayout->addWidget(param.edit, parameter.size(), 1);

			param.label->setToolTip(QString::fromStdString(var[i].description));
			param.edit->setToolTip(QString::fromStdString(var[i].description));

			if (var[i].flags & PARAMETER) {
				if (var[i].flags & DOUBLE) {
					param.edit->setValidator(new QDoubleValidator(param.edit));
					param.type = PARAMETER | DOUBLE;
				} else if (var[i].flags & UINTEGER) {
					QIntValidator *validator = new QIntValidator(param.edit);
					param.edit->setValidator(validator);
					validator->setBottom(0);
					param.type = PARAMETER | UINTEGER;
				} else if (var[i].flags & INTEGER) {
					param.edit->setValidator(new QIntValidator(param.edit));
					param.type = PARAMETER | INTEGER;
				} else
					param.type = PARAMETER;
				param.index = nparam++;
				param.str_value = new QString;
			} else if (var[i].flags & STATE) {
				param.edit->setReadOnly(true);
				palette.setBrush(param.edit->foregroundRole(), Qt::darkGray);
				param.edit->setPalette(palette);
				param.type = STATE;
				param.index = nstate++;
			} else if (var[i].flags & EVENT) {
				param.edit->setReadOnly(true);
				param.type = EVENT;
				param.index = nevent++;
			} else if (var[i].flags & COMMENT) {
				param.type = COMMENT;
				param.index = ncomment++;
			}
			parameter[QString::fromStdString(var[i].name)] = param;
		}
	}

	// Create child widget
	buttonGroup = new QGroupBox;
	QHBoxLayout *buttonLayout = new QHBoxLayout;

	// Create elements
	pauseButton = new QPushButton("Pause", this);
	pauseButton->setCheckable(true);
	QObject::connect(pauseButton,SIGNAL(toggled(bool)),this,SLOT(pause(bool)));
	buttonLayout->addWidget(pauseButton);

	modifyButton = new QPushButton("Modify", this);
	QObject::connect(modifyButton,SIGNAL(clicked(void)),this,SLOT(modify(void)));
	buttonLayout->addWidget(modifyButton);

	unloadButton = new QPushButton("Unload", this);
	QObject::connect(unloadButton,SIGNAL(clicked(void)),this,SLOT(exit(void)));
	buttonLayout->addWidget(unloadButton);

	// Add layout to box
	gridBox->setLayout(gridLayout);
	buttonGroup->setLayout(buttonLayout);

	// Keep one row of space above for users to place in grid
	layout->addWidget(gridBox, 1, 0);

	// Attempt to put these at the bottom at all times
	layout->addWidget(buttonGroup, 10, 0);

	// Set layout to Mdi and show
	setLayout(layout);
	subWindow->setAttribute(Qt::WA_DeleteOnClose);
	subWindow->setWidget(this);
	subWindow->show();
}
Exemplo n.º 25
0
GraphicalValue * GraphicalValue::createFromOption(Option::ConstPtr option,
                                                  QWidget * parent)
{
  GraphicalValue * value = nullptr;

  if(option.get() == nullptr)
    return value;

  std::string tag(option->tag());

  if(tag != "array" )
  {
    if(option->has_restricted_list())
      value = new GraphicalRestrictedList(option, parent);
    else
    {
      std::string type(option->type());

      if(type == Protocol::Tags::type<bool>())               // bool option
        value = new GraphicalBool(option->value<bool>(), parent);
      else if(type == Protocol::Tags::type<Real>())          // Real option
        value = new GraphicalDouble(option->value<Real>(), parent);
      else if(type == Protocol::Tags::type<int>())           // int option
        value = new GraphicalInt(false, option->value<int>(), parent);
      else if(type == Protocol::Tags::type<Uint>())          // Uint option
        value = new GraphicalInt(true, option->value<Uint>(), parent);
      else if(type == Protocol::Tags::type<std::string>())   // string option
        value = new GraphicalString(option->value<std::string>().c_str(), parent);
      else if(type == Protocol::Tags::type<URI>())           // URI option
        value = new GraphicalUri(boost::dynamic_pointer_cast<OptionURI const>(option), parent);
      else
        throw CastingFailed(FromHere(), tag + ": Unknown type");
    }
  }
  else
  {
    if(option->has_restricted_list())
      value = new GraphicalArrayRestrictedList(option, parent);
    else
    {
      OptionArray::ConstPtr array = boost::dynamic_pointer_cast<OptionArray const>(option);
      std::string value_str( array->value_str() );
      std::string type( array->elem_type() );
      QString sep( array->separator().c_str() );

      if(type == Protocol::Tags::type<bool>())                 // bool option
      {
        QRegExp regex("(true)|(false)|(1)|(0)|(on)|(off)");
        value = new GraphicalArray(new QRegExpValidator(regex, parent), sep, parent);
      }
      else if(type == Protocol::Tags::type<Real>())            // Real option
      {
        QDoubleValidator * val = new QDoubleValidator(nullptr);
        val->setNotation(QDoubleValidator::ScientificNotation);
        value = new GraphicalArray(val, sep, parent);
      }
      else if(type == Protocol::Tags::type<int>())              // int option
        value = new GraphicalArray(new QIntValidator(), sep, parent);
      else if(type == Protocol::Tags::type<Uint>())             // Uint option
      {
        QIntValidator * val = new QIntValidator();
        val->setBottom(0);
        value = new GraphicalArray(val, sep, parent);
      }
      else if(type == Protocol::Tags::type<std::string>())      // string option
        value = new GraphicalArray(nullptr,sep,  parent);
      else if(type == Protocol::Tags::type<URI>())              // URI option
        value = new GraphicalUriArray(sep, parent);
      else
        throw CastingFailed(FromHere(), tag + ": Unknown type");

      value->setValue( QString(value_str.c_str()).split(array->separator().c_str()) );
    }
  }
  return value;
}
Exemplo n.º 26
0
void MainWindow::createActions()
{
    //saveToXML = new QAction(QIcon(":/images/save.png"), tr("&Save..."), this);
    //saveToXML = new QAction(("&Save..."), this);
    //saveToXML->setShortcuts(QKeySequence::Save);
    //saveToXML->setStatusTip(tr("Save your current sketch to an XML file"));
    //saveToXML->setText("Save");
    //connect(saveToXML, SIGNAL(triggered()), this, SLOT(saveTreeToXML()));

    newSketch = new QAction(("&New"), this);
    newSketch->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
    newSketch->setStatusTip(tr("Start a new sketch"));
    connect(newSketch, SIGNAL(triggered()), this, SLOT(clearSketch()));

    generate = new QAction(("&Generate"), this);
    generate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_G));
    generate->setStatusTip(tr("Generate a tree from your current sketch"));
    connect(generate, SIGNAL(triggered()), this, SLOT(generateFromCurrent()));
    generate->setEnabled(false);

    generationOption = new QAction(("&Options"), this);
    generationOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
    generationOption->setStatusTip(tr("Choose settings for the tree generation process"));
    connect(generationOption, SIGNAL(triggered()), this, SLOT(generationOptions()));

    newVariation = new QAction(("&New Variation"), this);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    newVariation->setStatusTip(tr("Generate a new variation of the last type of tree you generated"));
    connect(newVariation, SIGNAL(triggered()), this, SLOT(generateNewVariation()));
    newVariation->setEnabled(false);


    displayFoliage = new QCheckBox(("&Foliage"), this);
    displayFoliage->setChecked(true);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displayFoliage->setStatusTip(tr("Display foliage"));
    connect(displayFoliage, SIGNAL(toggled(bool)), this, SLOT(toggleFoliage( bool)));
    displayFoliage->setEnabled(false);
    displayFoliage->setChecked(true);

    displayTexture = new QCheckBox(("&Texture"), this);
    displayTexture->setChecked(true);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displayTexture->setStatusTip(tr("Display texture"));
    connect(displayTexture, SIGNAL(toggled(bool)), this, SLOT(toggleTexture(bool)));
    displayTexture->setEnabled(false);
    displayTexture->setChecked(true);

    displaySubdivisionSurface = new QCheckBox(("&Subdivision Surface"), this);
    //newVariation->setShortcuts(QKeySequence(Qt::CTRL + Qt::Key_G));
    displaySubdivisionSurface->setStatusTip(tr("Generate a subdivision surface for the trunk and branches"));
    displaySubdivisionSurface->setChecked(true);
    connect(displaySubdivisionSurface, SIGNAL(toggled(bool)), this, SLOT(displayAsMesh(bool)));
    displaySubdivisionSurface->setEnabled(false);

    SubdivSpinBox = new QSpinBox();
    SubdivSpinBox->setSingleStep(1);
    SubdivSpinBox->setMaximumWidth(40);
    SubdivSpinBox->setValue(subdivs);
    SubdivSpinBox->setMaximum(3);
    SubdivSpinBox->setEnabled(false);

    connect(SubdivSpinBox, SIGNAL( valueChanged(int)), this, SLOT(SubdivSliderChange(int)));


    undo = new QAction(QIcon("./Resources/Icons/Undo.png"),("&Undo"), this);
    undo->setStatusTip(tr("Undo your last action"));
    connect(undo, SIGNAL(triggered()), this, SLOT(undoAction()));

    redo = new QAction(QIcon("./Resources/Icons/Redo.png"),("&Redo"), this);
    redo->setStatusTip(tr("Redo your last undone action"));
    connect(redo, SIGNAL(triggered()), this, SLOT(redoAction()));

    //viewXML = new QAction(("&Display XML file..."), this);
    //connect(viewXML, SIGNAL(triggered()), this, SLOT(viewXMLAction()));

    //viewLST = new QAction(("&Display LST file..."), this);
    //connect(viewLST, SIGNAL(triggered()), this, SLOT(viewLSTAction()));

    lineMode = new QToolButton(this);
    lineMode->setText("Line Mode");
    lineMode->setIcon(QIcon("./Resources/Icons/LineMode.png"));
    lineMode->setStatusTip(tr("Change to line drawing mode in the sketch interface"));
    connect(lineMode, SIGNAL(clicked()), this, SLOT(setLineMode()));
    lineMode->setCheckable(true);
    lineMode->setChecked(true);
    lineMode->setAutoExclusive(true);

    selectMode = new QToolButton(this);
    selectMode->setText("Select Mode");
    selectMode->setIcon(QIcon("./Resources/Icons/SelectMode.png"));
    selectMode->setStatusTip(tr("Change to selection mode in the sketch interface"));
    connect(selectMode, SIGNAL(clicked()), this, SLOT(setSelectMode()));
    selectMode->setCheckable(true);
    selectMode->setAutoExclusive(true);

    pencilMode = new QToolButton(this);
    pencilMode->setText("Pencil Mode");
    pencilMode->setIcon(QIcon("./Resources/Icons/PencilMode.png"));
    pencilMode->setStatusTip(tr("Change to pencil drawing mode in the sketch interface"));
    connect(pencilMode, SIGNAL(clicked()), this, SLOT(setPencilMode()));
    pencilMode->setCheckable(true);
    pencilMode->setAutoExclusive(true);

    brushSize = new QComboBox(this);
    QIntValidator *val = new QIntValidator(brushSize);
    val->setRange(3, 30);
    brushSize->setValidator(val);
    connect(brushSize, SIGNAL(activated(const QString&)), this, SLOT(setBrushSize(const QString&)));
    for (int i=0; i<BRUSH_SIZE_COUNT; ++i)
    {
        QString s;
        s.setNum(BRUSH_SIZE_OPTION[i]);
        brushSize->insertItem(i+1, s);
    }

    brushLabel = new QLabel(this);
    brushLabel->setText(" Brush size:  ");


    texSynthOption = new QAction(("&Synthesize Texture"), this);
    //  texSynthOption->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
    texSynthOption->setStatusTip(tr("Synthesize a new texture from a sample"));
    connect(texSynthOption, SIGNAL(triggered()), this,SLOT(SynthesizeTexture()));

}
Exemplo n.º 27
0
void
MyPluginGUI::createGUI(DefaultGUIModel::variable_t *var, int size)
{

  setMinimumSize(200, 300); // Qt API for setting window size

  //overall GUI layout with a "horizontal box" copied from DefaultGUIModel

  QBoxLayout *layout = new QHBoxLayout(this);

  //additional GUI layouts with "vertical" layouts that will later
  // be added to the overall "layout" above
  QBoxLayout *leftlayout = new QVBoxLayout();
  //QBoxLayout *rightlayout = new QVBoxLayout();

  // this is a "horizontal button group"
  QHButtonGroup *bttnGroup = new QHButtonGroup("Button Panel:", this);

  // we add two pushbuttons to the button group
  QPushButton *aBttn = new QPushButton("Button A", bttnGroup);
  QPushButton *bBttn = new QPushButton("Button B", bttnGroup);

  // clicked() is a Qt signal that is given to pushbuttons. The connect()
  // function links the clicked() event to a function that is defined
  // as a "private slot:" in the header.
  QObject::connect(aBttn, SIGNAL(clicked()), this, SLOT(aBttn_event()));
  QObject::connect(bBttn, SIGNAL(clicked()), this, SLOT(bBttn_event()));

  //these 3 utility buttons are copied from DefaultGUIModel
  QHBox *utilityBox = new QHBox(this);
  pauseButton = new QPushButton("Pause", utilityBox);
  pauseButton->setToggleButton(true);
  QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
  QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
  QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
  QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
  QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));

  // add custom button group at the top of the layout
  leftlayout->addWidget(bttnGroup);

  // copied from DefaultGUIModel DO NOT EDIT
  // this generates the text boxes and labels
  QScrollView *sv = new QScrollView(this);
  sv->setResizePolicy(QScrollView::AutoOneFit);
  leftlayout->addWidget(sv);

  QWidget *viewport = new QWidget(sv->viewport());
  sv->addChild(viewport);
  QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);

  size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
  for (size_t i = 0; i < num_vars; i++)
    {
      if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
        {
          param_t param;

          param.label = new QLabel(vars[i].name, viewport);
          scrollLayout->addWidget(param.label, parameter.size(), 0);
          param.edit = new DefaultGUILineEdit(viewport);
          scrollLayout->addWidget(param.edit, parameter.size(), 1);

          QToolTip::add(param.label, vars[i].description);
          QToolTip::add(param.edit, vars[i].description);

          if (vars[i].flags & PARAMETER)
            {
              if (vars[i].flags & DOUBLE)
                {
                  param.edit->setValidator(new QDoubleValidator(param.edit));
                  param.type = PARAMETER | DOUBLE;
                }
              else if (vars[i].flags & UINTEGER)
                {
                  QIntValidator *validator = new QIntValidator(param.edit);
                  param.edit->setValidator(validator);
                  validator->setBottom(0);
                  param.type = PARAMETER | UINTEGER;
                }
              else if (vars[i].flags & INTEGER)
                {
                  param.edit->setValidator(new QIntValidator(param.edit));
                  param.type = PARAMETER | INTEGER;
                }
              else
                param.type = PARAMETER;
              param.index = nparam++;
              param.str_value = new QString;
            }
          else if (vars[i].flags & STATE)
            {
              param.edit->setReadOnly(true);
              param.edit->setPaletteForegroundColor(Qt::darkGray);
              param.type = STATE;
              param.index = nstate++;
            }
          else if (vars[i].flags & EVENT)
            {
              param.edit->setReadOnly(true);
              param.type = EVENT;
              param.index = nevent++;
            }
          else if (vars[i].flags & COMMENT)
            {
              param.type = COMMENT;
              param.index = ncomment++;
            }

          parameter[vars[i].name] = param;
        }
    }

  // end DO NOT EDIT

  // add the 3 utility buttons to the bottom of the layout
  leftlayout->addWidget(utilityBox);

  // layouts can contain other layouts. if you added components to
  // "rightlayout" and added "rightlayout" to "layout," you would
  // have left and right panels in your custom GUI.
  layout->addLayout(leftlayout);
  //layout->addLayout(rightlayout);

  show(); // this line is required to render the GUI
}
Exemplo n.º 28
0
FunctionSegmentViewer::FunctionSegmentViewer(QWidget *parent,
                                             FunctionSheet *sheet,
                                             FunctionPanel *panel)
    : QFrame(parent)
    , m_curve(0)
    , m_r0(0)
    , m_r1(0)
    , m_sheet(sheet)
    , m_xshHandle(0)
    , m_panel(panel) {
  setObjectName("FunctionSegmentViewer");

  m_pages[0] = new FunctionEmptySegmentPage(this);
  m_pages[1] = new SpeedInOutSegmentPage(this);
  m_pages[2] = new EaseInOutSegmentPage(false, this);
  m_pages[3] = new EaseInOutSegmentPage(true, this);
  m_pages[4] = new FunctionEmptySegmentPage(this);
  m_pages[5] = new FunctionExpressionSegmentPage(this);
  m_pages[6] = new FileSegmentPage(this);
  m_pages[7] = new FunctionEmptySegmentPage(this);
  m_pages[8] = new SimilarShapeSegmentPage(this);

  m_typeId[0] = TDoubleKeyframe::Linear;
  m_typeId[1] = TDoubleKeyframe::SpeedInOut;
  m_typeId[2] = TDoubleKeyframe::EaseInOut;
  m_typeId[3] = TDoubleKeyframe::EaseInOutPercentage;
  m_typeId[4] = TDoubleKeyframe::Exponential;
  m_typeId[5] = TDoubleKeyframe::Expression;
  m_typeId[6] = TDoubleKeyframe::File;
  m_typeId[7] = TDoubleKeyframe::Constant;
  m_typeId[8] = TDoubleKeyframe::SimilarShape;

  m_typeCombo = new QComboBox;
  m_typeCombo->addItem(tr("Linear"));
  m_typeCombo->addItem(tr("Speed In / Speed Out"));
  m_typeCombo->addItem(tr("Ease In / Ease Out"));
  m_typeCombo->addItem(tr("Ease In / Ease Out %"));
  m_typeCombo->addItem(tr("Exponential"));
  m_typeCombo->addItem(tr("Expression"));
  m_typeCombo->addItem(tr("File"));
  m_typeCombo->addItem(tr("Constant"));
  m_typeCombo->addItem(tr("Similar Shape"));
  m_typeCombo->setCurrentIndex(7);

  //---- common interfaces
  m_fromFld        = new QLineEdit(this);
  m_toFld          = new QLineEdit(this);
  m_paramNameLabel = new QLabel("", this);

  QLabel *typeLabel = new QLabel(tr("Interpolation:"));
  typeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  m_stepFld = new LineEdit();

  // bottom part: stacked widget
  m_parametersPanel = new QStackedWidget;
  m_parametersPanel->setObjectName("FunctionParametersPanel");

  for (int i = 0; i < tArrayCount(m_pages); i++)
    m_parametersPanel->addWidget(m_pages[i]);
  m_parametersPanel->setCurrentIndex(0);

  // buttons
  QPushButton *applyButton = new QPushButton(tr("Apply"), this);
  m_prevCurveButton        = new QPushButton(this);
  m_nextCurveButton        = new QPushButton(this);
  m_prevLinkButton         = new QPushButton(this);
  m_nextLinkButton         = new QPushButton(this);

  //-----
  QIntValidator *intValidator = new QIntValidator(1, 100, this);
  m_stepFld->setValidator(intValidator);

  QIntValidator *validator = new QIntValidator(this);
  validator->setBottom(1);
  m_fromFld->setValidator(validator);
  m_toFld->setValidator(validator);

  m_stepFld->setEnabled(true);

  applyButton->setFocusPolicy(Qt::NoFocus);

  m_stepFld->setText("1");

  m_prevCurveButton->setFixedSize(50, 15);
  m_nextCurveButton->setFixedSize(50, 15);
  m_prevCurveButton->setFocusPolicy(Qt::NoFocus);
  m_nextCurveButton->setFocusPolicy(Qt::NoFocus);
  m_prevCurveButton->setStyleSheet("padding:0px;");
  m_nextCurveButton->setStyleSheet("padding:0px;");

  m_prevLinkButton->setFixedSize(15, 15);
  m_nextLinkButton->setFixedSize(15, 15);
  m_prevLinkButton->setCheckable(true);
  m_nextLinkButton->setCheckable(true);
  m_prevLinkButton->setFocusPolicy(Qt::NoFocus);
  m_nextLinkButton->setFocusPolicy(Qt::NoFocus);
  m_prevLinkButton->setObjectName("FunctionSegmentViewerLinkButton");
  m_nextLinkButton->setObjectName("FunctionSegmentViewerLinkButton");

  //---- layout

  QVBoxLayout *mainLayout = new QVBoxLayout();
  mainLayout->setSpacing(5);
  mainLayout->setMargin(5);
  {
    m_topbar                  = new QWidget();
    QVBoxLayout *topbarLayout = new QVBoxLayout();
    topbarLayout->setSpacing(5);
    topbarLayout->setMargin(0);
    {
      topbarLayout->addWidget(m_paramNameLabel);

      QHBoxLayout *upperLay = new QHBoxLayout();
      upperLay->setSpacing(3);
      upperLay->setMargin(0);
      {
        upperLay->addWidget(new QLabel(tr("From"), this), 0);
        upperLay->addWidget(m_fromFld, 1);
        upperLay->addSpacing(3);
        upperLay->addWidget(new QLabel(tr("To"), this), 0);
        upperLay->addWidget(m_toFld, 1);
        upperLay->addSpacing(5);
        upperLay->addWidget(new QLabel(tr("Step"), this), 0);
        upperLay->addWidget(m_stepFld, 1);
      }
      topbarLayout->addLayout(upperLay, 0);

      QHBoxLayout *bottomLay = new QHBoxLayout();
      bottomLay->setSpacing(3);
      bottomLay->setMargin(0);
      {
        bottomLay->addWidget(typeLabel, 0);
        bottomLay->addWidget(m_typeCombo, 1);
      }
      topbarLayout->addLayout(bottomLay, 0);
    }
    // end topbar
    m_topbar->setLayout(topbarLayout);

    mainLayout->addWidget(m_topbar, 0);
    mainLayout->addWidget(m_parametersPanel, 0);
    mainLayout->addStretch(1);

    mainLayout->addWidget(applyButton);

    QHBoxLayout *moveLay = new QHBoxLayout();
    moveLay->setMargin(0);
    moveLay->setSpacing(0);
    {
      moveLay->addWidget(m_prevCurveButton, 0);
      moveLay->addWidget(m_prevLinkButton, 0);
      moveLay->addStretch(1);
      moveLay->addWidget(m_nextLinkButton, 0);
      moveLay->addWidget(m_nextCurveButton, 0);
    }
    mainLayout->addLayout(moveLay, 0);
  }
  setLayout(mainLayout);

  //---- signal-slot connections
  bool ret = true;
  ret      = ret && connect(m_typeCombo, SIGNAL(currentIndexChanged(int)),
                       m_parametersPanel, SLOT(setCurrentIndex(int)));
  ret = ret && connect(m_typeCombo, SIGNAL(activated(int)), this,
                       SLOT(onSegmentTypeChanged(int)));
  ret = ret && connect(applyButton, SIGNAL(clicked()), this,
                       SLOT(onApplyButtonPressed()));
  ret = ret && connect(m_prevCurveButton, SIGNAL(clicked()), this,
                       SLOT(onPrevCurveButtonPressed()));
  ret = ret && connect(m_nextCurveButton, SIGNAL(clicked()), this,
                       SLOT(onNextCurveButtonPressed()));
  ret = ret && connect(m_prevLinkButton, SIGNAL(clicked()), this,
                       SLOT(onPrevLinkButtonPressed()));
  ret = ret && connect(m_nextLinkButton, SIGNAL(clicked()), this,
                       SLOT(onNextLinkButtonPressed()));
  assert(ret);

  m_sheet = sheet;
  refresh();
}
Exemplo n.º 29
0
QWidget* BusPortsDelegate::createEditor( QWidget* parent, 
										const QStyleOptionViewItem& option,
										const QModelIndex& index ) const {

	switch (index.column()) {
		// name and comment need only normal QLineEdit
		case 0:
		case 8: {
			QLineEdit* line = new QLineEdit(parent);
			connect(line, SIGNAL(editingFinished()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return line;
			  }
		// qualifier
		case 1: {
			QComboBox* box = new QComboBox(parent);
			QStringList list;
			list.append(QString("address"));
			list.append(QString("data"));
			list.append(QString("clock"));
			list.append(QString("reset"));
			list.append(QString("any"));
			box->addItems(list);
			return box;
				}
		// width
		case 2: {
            QLineEdit* line = new QLineEdit(parent);

            // the validator for editor input
            QRegExpValidator* validator = new QRegExpValidator(QRegExp("[0-9]{0,5}"), line);

            line->setValidator(validator);

            connect(line, SIGNAL(editingFinished()),
                this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
            return line;
				}
		// default value
		case 3: {
			// the editor
			QLineEdit* line = new QLineEdit(parent);

			// the validator for editor input
			QIntValidator* validator = new QIntValidator(line);
			validator->setRange(0, 99999);

			line->setValidator(validator);

			connect(line, SIGNAL(editingFinished()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return line;
				}
		// mode
		case 4: {
			QComboBox* box = new QComboBox(parent);
			QStringList list;
			list.append(QString("master"));
			list.append(QString("slave"));
			list.append(QString("system"));
			list.append(QString("any"));
			box->addItems(list);
			connect(box, SIGNAL(destroyed()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return box;
				}
		// direction of the port
		case 5: {
			QComboBox* box = new QComboBox(parent);
			QStringList list;
			list.append(QString("in"));
			list.append(QString("out"));
			list.append(QString("inout"));
			box->addItems(list);
			connect(box, SIGNAL(destroyed()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return box;
				}
		// presence
		case 6: {
			QComboBox* box = new QComboBox(parent);
			QStringList list;
			list.append(QString("required"));
			list.append(QString("optional"));
			list.append(QString("illegal"));
			box->addItems(list);
			connect(box, SIGNAL(destroyed()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return box;
				}
		// driver
		case 7: {
			QComboBox* box = new QComboBox(parent);
			QStringList list;
			list.append(QString("none"));
			list.append(QString("any"));
			list.append(QString("clock"));
			list.append(QString("singleshot"));
			box->addItems(list);
			connect(box, SIGNAL(destroyed()),
				this, SLOT(commitAndCloseEditor()), Qt::UniqueConnection);
			return box;
				}
		
		default: {
			return QStyledItemDelegate::createEditor(parent, option, index);
				 }
	}
}
Exemplo n.º 30
0
bool Perfboard::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
	if (prop.compare("size", Qt::CaseInsensitive) == 0) {
		returnProp = tr("size");
		returnValue = m_size;
		m_propsMap.insert("size", m_size);

		int x, y;
		getXY(x, y, m_size);

		QFrame * frame = new QFrame();
		QVBoxLayout * vboxLayout = new QVBoxLayout();
		vboxLayout->setAlignment(Qt::AlignLeft);
		vboxLayout->setSpacing(1);
		vboxLayout->setContentsMargins(0, 3, 0, 0);
		vboxLayout->setMargin(0);

		QFrame * subframe1 = new QFrame();
		QHBoxLayout * hboxLayout1 = new QHBoxLayout();
		hboxLayout1->setAlignment(Qt::AlignLeft);
		hboxLayout1->setContentsMargins(0, 0, 0, 0);
		hboxLayout1->setSpacing(2);

		QLabel * l1 = new QLabel(getRowLabel());	
		l1->setMargin(0);
		l1->setObjectName("infoViewLabel");	
		m_xEdit = new QLineEdit();
		m_xEdit->setEnabled(swappingEnabled);
		QIntValidator * validator = new QIntValidator(m_xEdit);
		validator->setRange(MinXDimension, MaxXDimension);
		m_xEdit->setObjectName("infoViewLineEdit");	
		m_xEdit->setValidator(validator);
		m_xEdit->setMaxLength(5);
		m_xEdit->setText(QString::number(x));

		QFrame * subframe2 = new QFrame();
		QHBoxLayout * hboxLayout2 = new QHBoxLayout();
		hboxLayout2->setAlignment(Qt::AlignLeft);
		hboxLayout2->setContentsMargins(0, 0, 0, 0);
		hboxLayout2->setSpacing(2);

		QLabel * l2 = new QLabel(getColumnLabel());
		l2->setMargin(0);
		l2->setObjectName("infoViewLabel");	
		m_yEdit = new QLineEdit();
		m_yEdit->setEnabled(swappingEnabled);
		validator = new QIntValidator(m_yEdit);
		validator->setRange(MinYDimension, MaxYDimension);
		m_yEdit->setObjectName("infoViewLineEdit");	
		m_yEdit->setValidator(validator);
		m_yEdit->setMaxLength(5);
		m_yEdit->setText(QString::number(y));

		hboxLayout1->addWidget(l1);
		hboxLayout1->addWidget(m_xEdit);

		hboxLayout2->addWidget(l2);
		hboxLayout2->addWidget(m_yEdit);

		subframe1->setLayout(hboxLayout1);
		subframe2->setLayout(hboxLayout2);

		if (returnWidget != NULL) vboxLayout->addWidget(qobject_cast<QWidget *>(returnWidget));
		vboxLayout->addWidget(subframe1);
		vboxLayout->addWidget(subframe2);

		m_setButton = new QPushButton (tr("set board size"));
		m_setButton->setObjectName("infoViewButton");
		connect(m_setButton, SIGNAL(pressed()), this, SLOT(changeBoardSize()));
		m_setButton->setEnabled(false);

		vboxLayout->addWidget(m_setButton);

		connect(m_xEdit, SIGNAL(editingFinished()), this, SLOT(enableSetButton()));
		connect(m_yEdit, SIGNAL(editingFinished()), this, SLOT(enableSetButton()));

		frame->setLayout(vboxLayout);

		returnWidget = frame;

		return true;
	}

	return Capacitor::collectExtraInfo(parent, family, prop, value, swappingEnabled, returnProp, returnValue, returnWidget);
}