Ejemplo n.º 1
0
/** The constructor for a single set of widgets containing parameters for the
 * scale of an axis.
 *  @param app :: the containing application window
 *  @param graph :: the graph the dialog is settign the options for
 *  @param mappedaxis :: the QwtPlot::axis value that corresponds to this axis
 *  @param parent :: the QWidget that acts as this widget's parent in the
 * hierarchy
 */
ScaleDetails::ScaleDetails(ApplicationWindow *app, Graph *graph, int mappedaxis,
                           QWidget *parent)
    : QWidget(parent) {
  m_app = app;
  m_graph = graph;
  m_mappedaxis = mappedaxis;
  m_initialised = false;
  m_modified = false;

  QGroupBox *middleBox = new QGroupBox(QString());
  QGridLayout *middleLayout = new QGridLayout(middleBox);

  m_lblStart = new QLabel(tr("From"));
  middleLayout->addWidget(m_lblStart, 0, 0);
  m_dspnStart = new DoubleSpinBox();
  m_dspnStart->setLocale(m_app->locale());
  m_dspnStart->setDecimals(m_app->d_graphing_digits);
  middleLayout->addWidget(m_dspnStart, 0, 1);
  connect(m_dspnStart, SIGNAL(valueChanged(double)), this,
          SLOT(recalcStepMin()));

  m_dteStartDateTime = new QDateTimeEdit();
  m_dteStartDateTime->setCalendarPopup(true);
  middleLayout->addWidget(m_dteStartDateTime, 0, 1);
  m_dteStartDateTime->hide();

  m_timStartTime = new QTimeEdit();
  middleLayout->addWidget(m_timStartTime, 0, 1);
  m_timStartTime->hide();

  m_lblEnd = new QLabel(tr("To"));
  middleLayout->addWidget(m_lblEnd, 1, 0);
  m_dspnEnd = new DoubleSpinBox();
  m_dspnEnd->setLocale(m_app->locale());
  m_dspnEnd->setDecimals(m_app->d_graphing_digits);
  middleLayout->addWidget(m_dspnEnd, 1, 1);
  connect(m_dspnStart, SIGNAL(valueChanged(double)), this,
          SLOT(recalcStepMin()));

  m_dteEndDateTime = new QDateTimeEdit();
  m_dteEndDateTime->setCalendarPopup(true);
  middleLayout->addWidget(m_dteEndDateTime, 1, 1);
  m_dteEndDateTime->hide();

  m_timEndTime = new QTimeEdit();
  middleLayout->addWidget(m_timEndTime, 1, 1);
  m_timEndTime->hide();

  m_lblScaleTypeLabel = new QLabel(tr("Type"));
  m_cmbScaleType = new QComboBox();
  m_cmbScaleType->addItem(tr("linear"));
  m_cmbScaleType->addItem(tr("logarithmic"));
  m_cmbScaleType->addItem(tr("power"));
  middleLayout->addWidget(m_lblScaleTypeLabel, 2, 0);
  middleLayout->addWidget(m_cmbScaleType, 2, 1);

  m_lblN = new QLabel(tr("n ="));
  m_dspnN = new DoubleSpinBox();
  m_dspnN->setLocale(m_app->locale());
  m_dspnN->setDecimals(m_app->d_graphing_digits);
  middleLayout->addWidget(m_lblN, 3, 0);
  middleLayout->addWidget(m_dspnN, 3, 1);

  m_lblWarn = new QLabel(tr(
      "Ensure axis and data ranges are\ncompatible with chosen axis scale."));
  middleLayout->addWidget(m_lblWarn, 4, 0, 1, 2);
  m_lblWarn->setVisible(false);

  m_chkInvert = new QCheckBox();
  m_chkInvert->setText(tr("Inverted"));
  m_chkInvert->setChecked(false);
  middleLayout->addWidget(m_chkInvert, 3, 1);
  middleLayout->setRowStretch(4, 1);
  // TODO: This is disabled because the code handling it's value is commented
  // out
  // Hence the value has no effect on the plot
  // THis was a UX issue in ticket #8198
  m_chkInvert->setVisible(false);

  m_grpAxesBreaks = new QGroupBox(tr("Show Axis &Break"));
  m_grpAxesBreaks->setCheckable(true);
  m_grpAxesBreaks->setChecked(false);

  QGridLayout *breaksLayout = new QGridLayout(m_grpAxesBreaks);
  m_chkBreakDecoration = new QCheckBox(tr("Draw Break &Decoration"));
  breaksLayout->addWidget(m_chkBreakDecoration, 0, 0, 1, 3);

  breaksLayout->addWidget(new QLabel(tr("From")), 1, 0);
  m_dspnBreakStart = new DoubleSpinBox();
  m_dspnBreakStart->setLocale(m_app->locale());
  m_dspnBreakStart->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnBreakStart, 1, 1);

  breaksLayout->addWidget(new QLabel(tr("To")), 2, 0);
  m_dspnBreakEnd = new DoubleSpinBox();
  m_dspnBreakEnd->setLocale(m_app->locale());
  m_dspnBreakEnd->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnBreakEnd, 2, 1);

  breaksLayout->addWidget(new QLabel(tr("Position")), 3, 0);
  m_spnBreakPosition = new QSpinBox();
  /* m_spnBreakPosition->setSuffix(" (" + tr("% of Axis Length") + ")"); */
  breaksLayout->addWidget(m_spnBreakPosition, 3, 1);
  breaksLayout->addWidget(new QLabel(tr("(% of Axis Length)")), 3, 2);

  breaksLayout->addWidget(new QLabel(tr("Width")), 4, 0);
  m_spnBreakWidth = new QSpinBox();
  /* m_spnBreakWidth->setSuffix(" (" + tr("pixels") + ")"); */
  breaksLayout->addWidget(m_spnBreakWidth, 4, 1);
  breaksLayout->addWidget(new QLabel(tr("(pixels)")), 4, 2);

  m_chkLog10AfterBreak = new QCheckBox(tr("&Log10 Scale After Break"));
  breaksLayout->addWidget(m_chkLog10AfterBreak, 0, 3);

  breaksLayout->addWidget(new QLabel(tr("Step Before Break")), 1, 3);
  m_dspnStepBeforeBreak = new DoubleSpinBox();
  m_dspnStepBeforeBreak->addSpecialTextMapping("Guess", 0.0);
  m_dspnStepBeforeBreak->addSpecialTextMapping("guess", 0.0);
  m_dspnStepBeforeBreak->addSpecialTextMapping("GUESS", 0.0);
  m_dspnStepBeforeBreak->setMinimum(0.0);
  m_dspnStepBeforeBreak->setSpecialValueText(tr("Guess"));
  m_dspnStepBeforeBreak->setLocale(m_app->locale());
  m_dspnStepBeforeBreak->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnStepBeforeBreak, 1, 4);

  breaksLayout->addWidget(new QLabel(tr("Step After Break")), 2, 3);
  m_dspnStepAfterBreak = new DoubleSpinBox();
  m_dspnStepAfterBreak->addSpecialTextMapping("Guess", 0.0);
  m_dspnStepAfterBreak->addSpecialTextMapping("guess", 0.0);
  m_dspnStepAfterBreak->addSpecialTextMapping("GUESS", 0.0);
  m_dspnStepAfterBreak->setMinimum(0.0);
  m_dspnStepAfterBreak->setSpecialValueText(tr("Guess"));
  m_dspnStepAfterBreak->setLocale(m_app->locale());
  m_dspnStepAfterBreak->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnStepAfterBreak, 2, 4);

  breaksLayout->addWidget(new QLabel(tr("Minor Ticks Before")), 3, 3);
  m_cmbMinorTicksBeforeBreak = new QComboBox();
  m_cmbMinorTicksBeforeBreak->setEditable(true);
  m_cmbMinorTicksBeforeBreak->addItems({"0", "1", "4", "9", "14", "19"});
  breaksLayout->addWidget(m_cmbMinorTicksBeforeBreak, 3, 4);

  breaksLayout->addWidget(new QLabel(tr("Minor Ticks After")), 4, 3);
  m_cmbMinorTicksAfterBreak = new QComboBox();
  m_cmbMinorTicksAfterBreak->setEditable(true);
  m_cmbMinorTicksAfterBreak->addItems({"0", "1", "4", "9", "14", "19"});
  breaksLayout->addWidget(m_cmbMinorTicksAfterBreak, 4, 4);

  QGroupBox *rightBox = new QGroupBox(QString());
  QGridLayout *rightLayout = new QGridLayout(rightBox);

  QWidget *stepWidget = new QWidget();
  QHBoxLayout *stepWidgetLayout = new QHBoxLayout(stepWidget);
  stepWidgetLayout->setMargin(0);

  m_radStep = new QRadioButton(tr("Step"));
  m_radStep->setChecked(true);
  rightLayout->addWidget(m_radStep, 0, 0);

  m_dspnStep = new DoubleSpinBox();
  m_dspnStep->setMinimum(0.0);
  m_dspnStep->setLocale(m_app->locale());
  m_dspnStep->setDecimals(m_app->d_decimal_digits);
  stepWidgetLayout->addWidget(m_dspnStep);

  m_cmbUnit = new QComboBox();
  m_cmbUnit->hide();
  stepWidgetLayout->addWidget(m_cmbUnit);

  rightLayout->addWidget(stepWidget, 0, 1);

  m_radMajor = new QRadioButton(tr("Max. Major Ticks"));
  rightLayout->addWidget(m_radMajor, 1, 0);

  m_spnMajorValue = new QSpinBox();
  m_spnMajorValue->setDisabled(true);
  m_spnMajorValue->setToolTip("Maximum number of major ticks which will be "
                              "added to the axis.\nNote that less ticks may be "
                              "added to preserve readability.");
  rightLayout->addWidget(m_spnMajorValue, 1, 1);

  m_lblMinorBox = new QLabel(tr("Max. Minor Ticks"));
  rightLayout->addWidget(m_lblMinorBox, 2, 0);

  m_cmbMinorValue = new QComboBox();
  m_cmbMinorValue->setEditable(true);
  m_cmbMinorValue->addItems({"0", "1", "4", "9", "14", "19"});
  m_cmbMinorValue->setToolTip("Maximum number of minor ticks which will be "
                              "added to the axis.\nNote that less ticks may be "
                              "added to preserve readability.");
  rightLayout->addWidget(m_cmbMinorValue, 2, 1);

  rightLayout->setRowStretch(3, 1);

  QHBoxLayout *hl = new QHBoxLayout();
  hl->addWidget(middleBox);
  hl->addWidget(rightBox);

  QVBoxLayout *vl = new QVBoxLayout(this);
  vl->addLayout(hl);
  vl->addWidget(m_grpAxesBreaks);

  connect(m_radStep, SIGNAL(clicked()), this, SLOT(radiosSwitched()));
  connect(m_radMajor, SIGNAL(clicked()), this, SLOT(radiosSwitched()));

  initWidgets();
  recalcStepMin();
}
Ejemplo n.º 2
0
/** The constructor for a single set of widgets containing parameters for the scale of an axis.
*  @param app :: the containing application window
*  @param graph :: the graph the dialog is settign the options for
*  @param mappedaxis :: the QwtPlot::axis value that corresponds to this axis
*  @param parent :: the QWidget that acts as this widget's parent in the hierachy
*/
ScaleDetails::ScaleDetails(ApplicationWindow* app, Graph* graph, int mappedaxis, QWidget *parent) : QWidget(parent)
{
  m_app = app;
  m_graph = graph;
  m_mappedaxis = mappedaxis;
  m_initialised = false;
  m_modified = false;

  QGroupBox * middleBox = new QGroupBox(QString());
  QGridLayout * middleLayout = new QGridLayout(middleBox);

  middleLayout->addWidget(new QLabel(tr("From")), 0, 0);
  m_dspnStart = new DoubleSpinBox();
  m_dspnStart->setLocale(m_app->locale());
  m_dspnStart->setDecimals(m_app->d_decimal_digits);
  middleLayout->addWidget(m_dspnStart, 0, 1);

  m_dteStartDateTime = new QDateTimeEdit();
  m_dteStartDateTime->setCalendarPopup(true);
  middleLayout->addWidget(m_dteStartDateTime, 0, 1);
  m_dteStartDateTime->hide();

  m_timStartTime = new QTimeEdit();
  middleLayout->addWidget(m_timStartTime, 0, 1);
  m_timStartTime->hide();

  middleLayout->addWidget(new QLabel(tr("To")), 1, 0);
  m_dspnEnd = new DoubleSpinBox();
  m_dspnEnd->setLocale(m_app->locale());
  m_dspnEnd->setDecimals(m_app->d_decimal_digits);
  middleLayout->addWidget(m_dspnEnd, 1, 1);

  m_dteEndDateTime = new QDateTimeEdit();
  m_dteEndDateTime->setCalendarPopup(true);
  middleLayout->addWidget(m_dteEndDateTime, 1, 1);
  m_dteEndDateTime->hide();

  m_timEndTime = new QTimeEdit();
  middleLayout->addWidget(m_timEndTime, 1, 1);
  m_timEndTime->hide();

  m_lblScaleTypeLabel = new QLabel(tr("Type"));
  m_cmbScaleType = new QComboBox();
  m_cmbScaleType->addItem(tr("linear"));
  m_cmbScaleType->addItem(tr("logarithmic"));
  middleLayout->addWidget(m_lblScaleTypeLabel, 2, 0);
  middleLayout->addWidget(m_cmbScaleType, 2, 1);

  m_chkInvert = new QCheckBox();
  m_chkInvert->setText(tr("Inverted"));
  m_chkInvert->setChecked(false);
  middleLayout->addWidget(m_chkInvert, 3, 1);
  middleLayout->setRowStretch(4, 1);

  m_grpAxesBreaks = new QGroupBox(tr("Show Axis &Break"));
  m_grpAxesBreaks->setCheckable(true);
  m_grpAxesBreaks->setChecked(false);

  QGridLayout * breaksLayout = new QGridLayout(m_grpAxesBreaks);
  m_chkBreakDecoration = new QCheckBox(tr("Draw Break &Decoration"));
  breaksLayout->addWidget(m_chkBreakDecoration, 0, 1);

  breaksLayout->addWidget(new QLabel(tr("From")), 1, 0);
  m_dspnBreakStart = new DoubleSpinBox();
  m_dspnBreakStart->setLocale(m_app->locale());
  m_dspnBreakStart->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnBreakStart, 1, 1);

  breaksLayout->addWidget(new QLabel(tr("To")), 2, 0);
  m_dspnBreakEnd = new DoubleSpinBox();
  m_dspnBreakEnd->setLocale(m_app->locale());
  m_dspnBreakEnd->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnBreakEnd, 2, 1);

  breaksLayout->addWidget(new QLabel(tr("Position")), 3, 0);
  m_spnBreakPosition = new QSpinBox();
  m_spnBreakPosition->setSuffix(" (" + tr("% of Axis Length") + ")");
  breaksLayout->addWidget(m_spnBreakPosition, 3, 1);

  breaksLayout->addWidget(new QLabel(tr("Width")), 4, 0);
  m_spnBreakWidth = new QSpinBox();
  m_spnBreakWidth->setSuffix(" (" + tr("pixels") + ")");
  breaksLayout->addWidget(m_spnBreakWidth, 4, 1);

  m_chkLog10AfterBreak = new QCheckBox(tr("&Log10 Scale After Break"));
  breaksLayout->addWidget(m_chkLog10AfterBreak, 0, 3);

  breaksLayout->addWidget(new QLabel(tr("Step Before Break")), 1, 2);
  m_dspnStepBeforeBreak = new DoubleSpinBox();
  m_dspnStepBeforeBreak->setMinimum(0.0);
  m_dspnStepBeforeBreak->setSpecialValueText(tr("Guess"));
  m_dspnStepBeforeBreak->setLocale(m_app->locale());
  m_dspnStepBeforeBreak->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnStepBeforeBreak, 1, 3);

  breaksLayout->addWidget(new QLabel(tr("Step After Break")), 2, 2);
  m_dspnStepAfterBreak = new DoubleSpinBox();
  m_dspnStepAfterBreak->setMinimum(0.0);
  m_dspnStepAfterBreak->setSpecialValueText(tr("Guess"));
  m_dspnStepAfterBreak->setLocale(m_app->locale());
  m_dspnStepAfterBreak->setDecimals(m_app->d_decimal_digits);
  breaksLayout->addWidget(m_dspnStepAfterBreak, 2, 3);

  breaksLayout->addWidget(new QLabel(tr("Minor Ticks Before")), 3, 2);
  m_cmbMinorTicksBeforeBreak = new QComboBox();
  m_cmbMinorTicksBeforeBreak->setEditable(true);
  m_cmbMinorTicksBeforeBreak->addItems(
    QStringList() << "0" << "1" << "4" << "9" << "14" << "19");
  breaksLayout->addWidget(m_cmbMinorTicksBeforeBreak, 3, 3);

  breaksLayout->addWidget(new QLabel(tr("Minor Ticks After")), 4, 2);
  m_cmbMinorTicksAfterBreak = new QComboBox();
  m_cmbMinorTicksAfterBreak->setEditable(true);
  m_cmbMinorTicksAfterBreak->addItems(
    QStringList() << "0" << "1" << "4" << "9" << "14" << "19");
  breaksLayout->addWidget(m_cmbMinorTicksAfterBreak, 4, 3);

  QGroupBox *rightBox = new QGroupBox(QString());
  QGridLayout *rightLayout = new QGridLayout(rightBox);

  QWidget * stepWidget = new QWidget();
  QHBoxLayout * stepWidgetLayout = new QHBoxLayout(stepWidget);
  stepWidgetLayout->setMargin(0);

  m_radStep = new QRadioButton(tr("Step"));
  m_radStep->setChecked(true);
  rightLayout->addWidget(m_radStep, 0, 0);

  m_dspnStep = new DoubleSpinBox();
  m_dspnStep->setMinimum(0.0);
  m_dspnStep->setLocale(m_app->locale());
  m_dspnStep->setDecimals(m_app->d_decimal_digits);
  stepWidgetLayout->addWidget(m_dspnStep);

  m_cmbUnit = new QComboBox();
  m_cmbUnit->hide();
  stepWidgetLayout->addWidget(m_cmbUnit);

  rightLayout->addWidget(stepWidget, 0, 1);

  m_radMajor = new QRadioButton(tr("Major Ticks"));
  rightLayout->addWidget(m_radMajor, 1, 0);

  m_spnMajorValue = new QSpinBox();
  m_spnMajorValue->setDisabled(true);
  rightLayout->addWidget(m_spnMajorValue, 1, 1);

  m_lblMinorBox = new QLabel(tr("Minor Ticks"));
  rightLayout->addWidget(m_lblMinorBox, 2, 0);

  m_cmbMinorValue = new QComboBox();
  m_cmbMinorValue->setEditable(true);
  m_cmbMinorValue->addItems(
    QStringList() << "0" << "1" << "4" << "9" << "14" << "19");
  rightLayout->addWidget(m_cmbMinorValue, 2, 1);

  rightLayout->setRowStretch(3, 1);

  QHBoxLayout* hl = new QHBoxLayout();
  hl->addWidget(middleBox);
  hl->addWidget(rightBox);

  QVBoxLayout* vl = new QVBoxLayout(this);
  vl->addLayout(hl);
  vl->addWidget(m_grpAxesBreaks);

  connect(m_radStep, SIGNAL(clicked()), this, SLOT(radiosSwitched()));
  connect(m_radMajor, SIGNAL(clicked()), this, SLOT(radiosSwitched()));

  initWidgets();
}