LabelCreator::LabelCreator(QWidget *parent) : QDialog(parent) { setupUi(this); setWindowTitle(tr("Create Label Dialog")); _bold->setFixedWidth(32); _bold->setFixedHeight(32); _bold->setIcon(QPixmap(":kst_bold.png")); _italic->setFixedWidth(32); _italic->setFixedHeight(32); _italic->setIcon(QPixmap(":kst_italic.png")); _labelColor->setFixedWidth(32); _labelColor->setFixedHeight(32); _labelText->setObjectStore(kstApp->mainWindow()->document()->objectStore()); QFont font; font.fromString(dialogDefaults().value("label/font",font.toString()).toString()); _family->setCurrentFont(font); _bold->setChecked(font.bold()); _italic->setChecked(font.italic()); _labelColor->setColor(dialogDefaults().value("label/color",QColor(Qt::black)).value<QColor>()); _labelFontScale->setValue(dialogDefaults().value("label/fontScale",12).toDouble()); if (dialogDefaults().value("label/fixLeft",true).toBool()) { _left->setChecked(true); } else { _right->setChecked(true); } _lockPosToData->setChecked(dialogDefaultsLockPosToData("label")); _saveAsDefault->show(); _Label_11->setProperty("si","Font &size:"); _Label_12->setProperty("si","Font famil&y:"); }
void setGenVectorDefaults(GeneratedVectorPtr V) { dialogDefaults().setValue("genVector/first", V->value(V->value(0))); dialogDefaults().setValue("genVector/last", V->value(V->length()-1)); dialogDefaults().setValue("genVector/min", V->min()); dialogDefaults().setValue("genVector/max", V->max()); dialogDefaults().setValue("genVector/length", V->length()); }
void LabelItem::applyDefaults() { QFont font; font.fromString(dialogDefaults().value(defaultsGroupName()+"/font",font.toString()).toString()); _font = font; _color = dialogDefaults().value(defaultsGroupName()+"/color",QColor(Qt::black)).value<QColor>(); _scale = dialogDefaults().value(defaultsGroupName()+"/fontScale",12).toDouble(); _fixleft = dialogDefaults().value(defaultsGroupName()+"/fixLeft",true).toBool(); applyDialogDefaultsLockPosToData(); }
void LegendItem::saveAsDialogDefaults() const { dialogDefaults().setValue(defaultsGroupName()+"/auto",_auto); dialogDefaults().setValue(defaultsGroupName()+"/title", _title); dialogDefaults().setValue(defaultsGroupName()+"/verticalDisplay", _verticalDisplay); QFont F = _font; F.setPointSize(_fontScale); saveDialogDefaultsFont(F, _color); saveDialogDefaultsPen(defaultsGroupName(), pen()); saveDialogDefaultsBrush(defaultsGroupName(), brush()); }
void LegendItem::applyDefaults() { _auto = dialogDefaults().value(defaultsGroupName()+"/auto",true).toBool(); _color = dialogDefaults().value(defaultsGroupName()+"/color",QColor(Qt::black)).value<QColor>(); QFont font; font.fromString(dialogDefaults().value(defaultsGroupName()+"/font",font.toString()).toString()); setLegendFont(font); setFontScale(dialogDefaults().value(defaultsGroupName()+"/fontScale", 12.0).toDouble()); _verticalDisplay = dialogDefaults().value(defaultsGroupName()+"/verticalDisplay",true).toBool(); }
void DataRange::loadWidgetDefaults() { setRange(dialogDefaults().value("vector/range", 1).toInt()); setStart(dialogDefaults().value("vector/start", 0).toInt()); setCountFromEnd(dialogDefaults().value("vector/countFromEnd",false).toBool()); setReadToEnd(dialogDefaults().value("vector/readToEnd",true).toBool()); setSkip(dialogDefaults().value("vector/skip", 0).toInt()); setDoSkip(dialogDefaults().value("vector/doSkip", false).toBool()); setDoFilter(dialogDefaults().value("vector/doAve",false).toBool()); setRangeUnits(dialogDefaults().value("vector/rangeUnits",tr("frames")).toString()); setStartUnits(dialogDefaults().value("vector/startUnits",tr("frames")).toString()); }
void DataRange::setWidgetDefaults() { //FIXME Do we need a V->readLock() here? dialogDefaults().setValue("vector/range", range()); dialogDefaults().setValue("vector/start", start()); dialogDefaults().setValue("vector/countFromEnd", countFromEnd()); dialogDefaults().setValue("vector/readToEnd", readToEnd()); dialogDefaults().setValue("vector/skip", skip()); dialogDefaults().setValue("vector/doSkip", doSkip()); dialogDefaults().setValue("vector/doAve", doFilter()); dialogDefaults().setValue("vector/rangeUnits", rangeUnits()); dialogDefaults().setValue("vector/startUnits", rangeUnits()); }
void VectorDialog::configureTab(ObjectPtr vector) { if (!vector) { _vectorTab->dataRange()->loadWidgetDefaults(); _vectorTab->setFile(dialogDefaults().value("vector/datasource",_vectorTab->file()).toString()); _vectorTab->setFrom(dialogDefaults().value("genVector/first",-10).toInt()); _vectorTab->setTo(dialogDefaults().value("genVector/last",10).toInt()); _vectorTab->setNumberOfSamples(dialogDefaults().value("genVector/length",1000).toInt()); _vectorTab->setVectorMode((VectorTab::VectorMode)dialogDefaults().value("genVector/vectorType",VectorTab::GeneratedVector).toInt()); // FIXME: should be sticky } else if (DataVectorPtr dataVector = kst_cast<DataVector>(vector)) { _vectorTab->setVectorMode(VectorTab::DataVector); _vectorTab->setFile(dataVector->dataSource()->fileName()); _vectorTab->setDataSource(dataVector->dataSource()); _vectorTab->updateIndexList(dataVector->dataSource()); _vectorTab->setField(dataVector->field()); _vectorTab->dataRange()->setRangeUnits(dataVector->rangeUnits()); if ( _vectorTab->dataRange()->rangeUnitsIndex()>0) { double frame_per_index = dataVector->dataSource()->framePerIndex(dataVector->startUnits()); if (frame_per_index == 0) { frame_per_index = 1.0; } _vectorTab->dataRange()->setRange(dataVector->numFrames()/frame_per_index); } else { _vectorTab->dataRange()->setRange(dataVector->numFrames()); } _vectorTab->dataRange()->setStartUnits(dataVector->startUnits()); if (_vectorTab->dataRange()->startUnitsIndex()>0) { _vectorTab->dataRange()->setStart(dataVector->dataSource()->frameToIndex(dataVector->startFrame(),dataVector->startUnits())); } else { _vectorTab->dataRange()->setStart(dataVector->startFrame()); } _vectorTab->dataRange()->setCountFromEnd(dataVector->countFromEOF()); _vectorTab->dataRange()->setReadToEnd(dataVector->readToEOF()); _vectorTab->dataRange()->setSkip(dataVector->skip()); _vectorTab->dataRange()->setDoSkip(dataVector->doSkip()); _vectorTab->dataRange()->setDoFilter(dataVector->doAve()); _vectorTab->hideGeneratedOptions(); if (_editMultipleWidget) { DataVectorList objects = _document->objectStore()->getObjects<DataVector>(); _editMultipleWidget->clearObjects(); foreach(DataVectorPtr object, objects) { _editMultipleWidget->addObject(object->Name(), object->descriptionTip()); } }
void saveDialogDefaultsBrush(const QString &group_name, const QBrush &b) { // Save the brush dialogDefaults().setValue(group_name+"/fillBrushColor", QVariant(b.color()).toString()); dialogDefaults().setValue(group_name+"/fillBrushStyle", QVariant((int)b.style()).toString()); dialogDefaults().setValue(group_name+"/fillBrushUseGradient", QVariant(bool(b.gradient())).toString()); if (b.gradient()) { QString stopList; foreach(const QGradientStop &stop, b.gradient()->stops()) { qreal point = (qreal)stop.first; QColor color = (QColor)stop.second; stopList += QString::number(point); stopList += ','; stopList += color.name(); stopList += ','; } dialogDefaults().setValue(group_name+"/fillBrushGradient", stopList); }
void setDataMatrixDefaults(DataMatrixPtr M) { //qDebug() << "M...filename: " << M->dataSource()->fileName(); // FIXME: data source filename isn't valid... dialogDefaults().setValue("matrix/datasource",M->dataSource()->fileName()); dialogDefaults().setValue("matrix/xCountFromEnd",M->xCountFromEnd()); dialogDefaults().setValue("matrix/yCountFromEnd",M->yCountFromEnd()); dialogDefaults().setValue("matrix/xReadToEnd",M->xReadToEnd()); dialogDefaults().setValue("matrix/yReadToEnd",M->yReadToEnd()); dialogDefaults().setValue("matrix/xNumSteps",M->xNumSteps()); dialogDefaults().setValue("matrix/yNumSteps",M->yNumSteps()); dialogDefaults().setValue("matrix/reqXStart",M->reqXStart()); dialogDefaults().setValue("matrix/reqYStart",M->reqYStart()); dialogDefaults().setValue("matrix/frame",M->frame()); }
void HistogramDialog::configureTab(ObjectPtr object) { if (!object) { _histogramTab->setRealTimeAutoBin(dialogDefaults().value("histogram/realTimeAutoBin", false).toBool()); _histogramTab->setNormalizationType(Histogram::NormalizationType(dialogDefaults().value("histogram/normalizationType",Histogram::Number).toInt())); } else if (HistogramPtr histogram = kst_cast<Histogram>(object)) { _histogramTab->setVector(histogram->vector()); _histogramTab->setMin(histogram->xMin()); _histogramTab->setMax(histogram->xMax()); _histogramTab->setBins(histogram->numberOfBins()); _histogramTab->setRealTimeAutoBin(histogram->realTimeAutoBin()); _histogramTab->setNormalizationType(histogram->normalizationType()); _histogramTab->hideCurveOptions(); if (_editMultipleWidget) { HistogramList objects = _document->objectStore()->getObjects<Histogram>(); _editMultipleWidget->clearObjects(); foreach(HistogramPtr object, objects) { _editMultipleWidget->addObject(object->Name(), object->descriptionTip()); } }
void StringDialog::configureTab(ObjectPtr object) { if (DataStringPtr dataString = kst_cast<DataString>(object)) { _stringTab->setFile(dataString->dataSource()->fileName()); _stringTab->setDataSource(dataString->dataSource()); _stringTab->setField(dataString->field()); _stringTab->hideGeneratedOptions(); } else if (StringPtr string = kst_cast<String>(object)) { // edit value string _stringTab->hideDataOptions(); _stringTab->setValue(string->value()); } else { // new string _stringTab->setFile(dialogDefaults().value("String/datasource",_stringTab->file()).toString()); } }
HistogramTab::HistogramTab(QWidget *parent) : DataTab(parent), _normalizationDirty(false) { setupUi(this); setTabTitle(tr("Histogram")); connect(AutoBin, SIGNAL(clicked()), this, SLOT(generateAutoBin())); connect(_realTimeAutoBin, SIGNAL(clicked()), this, SLOT(updateButtons())); connect(_vector, SIGNAL(selectionChanged(QString)), this, SLOT(selectionChanged())); connect(_vector, SIGNAL(selectionChanged(QString)), this, SIGNAL(modified())); connect(_min, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified())); connect(_max, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified())); connect(_numberOfBins, SIGNAL(valueChanged(int)), this, SIGNAL(modified())); connect(_realTimeAutoBin, SIGNAL(clicked()), this, SIGNAL(modified())); connect(_normalizationIsNumber, SIGNAL(clicked()), this, SIGNAL(modified())); connect(_normalizationIsFraction, SIGNAL(clicked()), this, SIGNAL(modified())); connect(_normalizationIsPercent, SIGNAL(clicked()), this, SIGNAL(modified())); connect(_normalizationMaximumOne, SIGNAL(clicked()), this, SIGNAL(modified())); connect(_normalizationIsNumber, SIGNAL(clicked()), this, SLOT(normalizationChanged())); connect(_normalizationIsFraction, SIGNAL(clicked()), this, SLOT(normalizationChanged())); connect(_normalizationIsPercent, SIGNAL(clicked()), this, SLOT(normalizationChanged())); connect(_normalizationMaximumOne, SIGNAL(clicked()), this, SLOT(normalizationChanged())); connect(_curvePlacement->_noPlot, SIGNAL(toggled(bool)), _curveAppearance, SLOT(setDisabled(bool))); _vectorLabel->setBuddy(_vector->_vector); _curvePlacement->setExistingPlots(Data::self()->plotList()); _curveAppearance->loadWidgetDefaults(); _curveAppearance->setShowLines(false); _curveAppearance->setShowPoints(false); _curveAppearance->setShowHead(false); _curveAppearance->setShowBars(true); _curveAppearance->setPointDensity(0); _curveAppearance->setColor(dialogDefaults().value("plot/strokeBrushColor",QColor(Qt::black)).value<QColor>()); _vectorLabel->setProperty("si","Data vecto&r:"); TextLabel1_4_2_2->setProperty("si","Bins from&:"); TextLabel4_5_2->setProperty("si","to:"); TextLabel5_2->setProperty("si","Num bin&s:"); AutoBin->setProperty("si","A&uto Bin"); _realTimeAutoBin->setProperty("si","Real&-time auto bin"); _normalizationIsPercent->setProperty("si","Percent& in bin"); _normalizationIsFraction->setProperty("si","&Fraction in bin"); _normalizationIsNumber->setProperty("si","Nu&mber in bin"); _normalizationMaximumOne->setProperty("si","Peak bin = &1.0"); }
void VectorSelector::newVector() { QString newName; if (_isX) { newName = dialogDefaults().value("curve/xvectorfield","INDEX").toString(); } DialogLauncher::self()->showVectorDialog(newName, 0, true); fillVectors(); VectorPtr vector = kst_cast<Vector>(_store->retrieveObject(newName)); if (vector) { setSelectedVector(vector); emitSelectionChanged(); emit contentChanged(); } }
void CreateLabelCommand::createItem(QString *inText) { if (inText) { _item = new LabelItem(_view, *inText); } else { bool ok = false; QString text; LabelCreator dialog; if (dialog.exec() == QDialog::Accepted) { text = dialog.labelText(); ok = true; } if (!ok || text.isEmpty()) { return; } _item = new LabelItem(_view, text); LabelItem *label = qobject_cast<LabelItem*>(_item); label->setLabelScale(dialog.labelScale()); label->setLabelColor(dialog.labelColor()); label->setLabelFont(dialog.labelFont()); label->setFixLeft(dialog.fixLeft()); label->setLockPosToData(dialog.lockPosToData()); if (dialog.saveAsDefaults()) { label->saveAsDialogDefaults(); dialogDefaults().setValue(label->staticDefaultsGroupName()+"/fixLeft",dialog.fixLeft()); dialogDefaults().setValue(label->staticDefaultsGroupName()+"/lockPosToData",dialog.lockPosToData()); } } _item->view()->scene()->addItem(_item); _view->setCursor(Qt::IBeamCursor); CreateCommand::createItem(); }
ChangeFileDialog::ChangeFileDialog(QWidget *parent) : QDialog(parent), _dataSource(0), _requestID(0) { setupUi(this); MainWindow::setWidgetFlags(this); if (MainWindow *mw = qobject_cast<MainWindow*>(parent)) { _store = mw->document()->objectStore(); } else { // FIXME: we need the object store qFatal("ERROR: can't construct a ChangeFileDialog without the object store"); } connect(_add, SIGNAL(clicked()), this, SLOT(addButtonClicked())); connect(_remove, SIGNAL(clicked()), this, SLOT(removeButtonClicked())); connect(_removeAll, SIGNAL(clicked()), this, SLOT(removeAll())); connect(_addAll, SIGNAL(clicked()), this, SLOT(addAll())); connect(_changeFilePrimitiveList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(availableDoubleClicked(QListWidgetItem*))); connect(_selectedFilePrimitiveList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(selectedDoubleClicked(QListWidgetItem*))); connect(_allFromFile, SIGNAL(clicked()), this, SLOT(selectAllFromFile())); connect(_changeFilePrimitiveList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons())); connect(_selectedFilePrimitiveList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons())); connect(_duplicateSelected, SIGNAL(toggled(bool)), _duplicateDependents, SLOT(setEnabled(bool))); connect(_dataFile, SIGNAL(changed(QString)), this, SLOT(fileNameChanged(QString))); connect(_dataFile, SIGNAL(destroyed()), kstApp->mainWindow(), SLOT(cleanUpDataSourceList())); connect(_buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); connect(_buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(OKClicked())); connect(_buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); connect(_configure, SIGNAL(clicked()), this, SLOT(showConfigWidget())); connect(UpdateServer::self(), SIGNAL(objectListsChanged()), this, SLOT(updatePrimitiveList())); _dataFile->setFile(dialogDefaults().value("changedatafile/newFileName",QDir::currentPath()).toString()); updateButtons(); }
void LabelItem::saveDialogDefaultsFont(const QFont &F, const QColor &C) { dialogDefaults().setValue(staticDefaultsGroupName()+"/font", QVariant(F).toString()); dialogDefaults().setValue(staticDefaultsGroupName()+"/color", C.name()); dialogDefaults().setValue(staticDefaultsGroupName()+"/fontScale", F.pointSize()); }
void setDataVectorDefaults(DataVectorPtr V) { dialogDefaults().setValue("vector/datasource", V->filename()); }
void setHistogramDefaults(HistogramPtr H) { dialogDefaults().setValue("histogram/realTimeAutoBin", H->realTimeAutoBin()); dialogDefaults().setValue("histogram/normalizationType",H->normalizationType()); }
void saveDialogDefaultsLockPosToData(const QString &group_name, const bool lockPosToData) { dialogDefaults().setValue(group_name+"/lockPosToData", QVariant(lockPosToData).toString()); }
namespace Kst { LogDialog::LogDialog(MainWindow *parent) : QDialog(parent), _logtime(0), _format(QString()), _logdir(QString()), _parent(parent) { setupUi(this); QStringList formats; foreach(const QByteArray &array, QImageWriter::supportedImageFormats()) { formats.append(QString(array)); } _formats->addItems(formats); _formats->setCurrentIndex( _formats->findText(dialogDefaults().value("log/format","png").toString())); _xSize->setValue(dialogDefaults().value("log/xsize","1024").toInt()); _ySize->setValue(dialogDefaults().value("log/ysize","768").toInt()); _sizeOption->setCurrentIndex(dialogDefaults().value("log/sizeOption","0").toInt()); enableWidthHeight(); _saveLocation->setFile(dialogDefaults().value("log/logdir",QDir::currentPath()).toString()); _script->setText(dialogDefaults().value("log/script", QString()).toString()); _tab->setCurrentIndex(0); _user->setText(dialogDefaults().value("log/user", QString()).toString());
} else if (dialogDefaults().value("wizard/pointsOnly", true).toBool()) { _drawPoints->setChecked(true); } else { _drawBoth->setChecked(true); } foreach (PlotItemInterface *plot, Data::self()->plotList()) { _existingPlotName->addItem(plot->plotName(), qVariantFromValue(plot)); } bool havePlots = _existingPlotName->count() > 0; _cycleExisting->setEnabled(havePlots); _existingPlot->setEnabled(havePlots); _existingPlotName->setEnabled(havePlots && _existingPlot->isChecked()); _plotLayoutBox->setEnabled(!_existingPlot->isChecked()); CurvePlotPlacement placement = static_cast<CurvePlotPlacement>(dialogDefaults().value("wizard/curvePlacement",MultiplePlots).toInt()); switch (placement) { case OnePlot: _onePlot->setChecked(true); break; case MultiplePlots: _multiplePlots->setChecked(true); break; case CyclePlotCount: _cycleThrough->setChecked(true); break; case CycleExisting: if (havePlots) { _cycleExisting->setChecked(true); } else { _multiplePlots->setChecked(true);
void DataWizardPagePlot::updatePlotBox() { _plotNumber->setValue(dialogDefaults().value("wizard/plotCount",2).toInt()); if (dialogDefaults().value("wizard/legendsAuto",true).toBool()) { _legendsOn->setChecked(true); } else if (dialogDefaults().value("wizard/legendsOn",false).toBool()) { _legendsAuto->setChecked(true); } else { _legendsOff->setChecked(true); } _psdLogX->setChecked(dialogDefaults().value("wizard/logX",false).toBool()); _psdLogY->setChecked(dialogDefaults().value("wizard/logY",false).toBool()); _legendsOn->setChecked(dialogDefaults().value("wizard/legendsOn",false).toBool()); _legendsAuto->setChecked(dialogDefaults().value("wizard/legendsAuto",false).toBool()); _legendsVertical->setChecked(dialogDefaults().value("legend/verticalDisplay",false).toBool()); _rescaleFonts->setChecked(dialogDefaults().value("wizard/rescaleFonts", true).toBool()); _shareAxis->setChecked(dialogDefaults().value("wizard/shareAxis", false).toBool()); _shareAxis->hide(); //FIXME - not done yet. if (dialogDefaults().value("wizard/linesOnly", true).toBool()) { _drawLines->setChecked(true); } else if (dialogDefaults().value("wizard/pointsOnly", true).toBool()) { _drawPoints->setChecked(true); } else { _drawBoth->setChecked(true); } foreach (PlotItemInterface *plot, Data::self()->plotList()) { _existingPlotName->addItem(plot->plotName(), qVariantFromValue(plot)); }