本文整理汇总了C++中Plot::axisScaleDraw方法的典型用法代码示例。如果您正苦于以下问题:C++ Plot::axisScaleDraw方法的具体用法?C++ Plot::axisScaleDraw怎么用?C++ Plot::axisScaleDraw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plot
的用法示例。
在下文中一共展示了Plot::axisScaleDraw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadData
//.........这里部分代码省略.........
}
} else if (xColType == Table::Date) {
for (int i = d_start_row; i <= d_end_row; i++) {
QString xval = d_table->text(i, xcol);
if (!xval.isEmpty()) {
date0 = QDateTime::fromString(xval, date_time_fmt);
if (date0.isValid())
break;
}
}
}
int size = 0;
for (int i = d_start_row; i <= d_end_row; i++) {
QString xval = d_table->text(i, xcol);
QString yval = d_table->text(i, ycol);
if (!xval.isEmpty() && !yval.isEmpty()) {
bool valid_data = true;
if (xColType == Table::Text) {
xLabels << xval;
X[size] = (double)(size + 1);
} else if (xColType == Table::Time) {
QTime time = QTime::fromString(xval, date_time_fmt);
if (time.isValid())
X[size] = time0.msecsTo(time);
} else if (xColType == Table::Date) {
QDateTime d = QDateTime::fromString(xval, date_time_fmt);
if (d.isValid())
X[size] = (double)date0.secsTo(d);
} else
X[size] = plot->locale().toDouble(xval, &valid_data);
if (yColType == Table::Text) {
yLabels << yval;
Y[size] = (double)(size + 1);
} else
Y[size] = plot->locale().toDouble(yval, &valid_data);
if (valid_data)
size++;
}
}
X.resize(size);
Y.resize(size);
// The code for calculating the waterfall offsets, that is here in QtiPlot,
// has been moved up to
// PlotCurve so that MantidCurve can access it as well.
if (g->isWaterfallPlot()) {
// Calculate the offsets
double a, b;
computeWaterfallOffsets(a, b);
}
// End re-jigged waterfall offset code
if (!size) {
remove();
return;
} else {
if (d_type == GraphOptions::HorizontalBars) {
setData(Y.data(), X.data(), size);
foreach (DataCurve *c, d_error_bars)
c->setData(Y.data(), X.data(), size);
} else {
setData(X.data(), Y.data(), size);
foreach (DataCurve *c, d_error_bars)
c->setData(X.data(), Y.data(), size);
}
if (xColType == Table::Text) {
if (d_type == GraphOptions::HorizontalBars)
g->setLabelsTextFormat(QwtPlot::yLeft, ScaleDraw::Text, d_x_column,
xLabels);
else
g->setLabelsTextFormat(QwtPlot::xBottom, ScaleDraw::Text, d_x_column,
xLabels);
} else if (xColType == Table::Time || xColType == Table::Date) {
int axis = QwtPlot::xBottom;
if (d_type == GraphOptions::HorizontalBars)
axis = QwtPlot::yLeft;
ScaleDraw *old_sd = static_cast<ScaleDraw *>(plot->axisScaleDraw(axis));
ScaleDraw *sd = new ScaleDraw(plot, old_sd);
if (xColType == Table::Date)
sd->setDateTimeOrigin(date0);
else
sd->setDateTimeOrigin(QDateTime(QDate::currentDate(), time0));
plot->setAxisScaleDraw(axis, sd);
}
if (yColType == Table::Text)
g->setLabelsTextFormat(QwtPlot::yLeft, ScaleDraw::Text, title().text(),
yLabels);
}
if (!d_labels_list.isEmpty()) {
(static_cast<Graph *>(plot->parent()))->updatePlot();
loadLabels();
}
}
示例2: initWidgets
/** Initialisation method. Sets up all widgets and variables not done in the constructor.
*
*/
void AxisDetails::initWidgets()
{
if (m_initialised)
{
return;
}
else
{
Plot *p = m_graph->plotWidget();
int style = (int) m_graph->axisType(m_mappedaxis);
bool axisOn = p->axisEnabled(m_mappedaxis);
const QList<int> majTicks = p->getMajorTicksType();
const QList<int> minTicks = p->getMinorTicksType();
const QwtScaleDraw *sd = p->axisScaleDraw(m_mappedaxis);
bool labelsOn = sd->hasComponent(QwtAbstractScaleDraw::Labels);
int format = p->axisLabelFormat(m_mappedaxis);
//Top
m_chkShowAxis->setChecked(axisOn);
m_txtTitle->setText(m_graph->axisTitle(m_mappedaxis));
m_labelFont = m_graph->axisTitleFont(m_mappedaxis);
//bottom left
m_cmbAxisType->setCurrentIndex(style);
setAxisFormatOptions(style);
m_scaleFont = p->axisFont(m_mappedaxis);
m_cbtnAxisColor->setColor(m_graph->axisColor(m_mappedaxis));
m_cmbMajorTicksType->setCurrentIndex(majTicks[m_mappedaxis]);
m_cmbMinorTicksType->setCurrentIndex(minTicks[m_mappedaxis]);
QwtScaleWidget *scale = dynamic_cast<QwtScaleWidget *>(p->axisWidget(m_mappedaxis));
if (scale)
{
m_spnBaseline->setValue(scale->margin());
}
else
{
m_spnBaseline->setValue(0);
}
//bottom right
m_grpShowLabels->setChecked(labelsOn);
m_cmbFormat->setEnabled(labelsOn && axisOn);
m_cmbFormat->setCurrentIndex(format);
if (m_cmbAxisType->currentIndex() == ScaleDraw::Numeric)
{
m_spnPrecision->setValue(p->axisLabelPrecision(m_mappedaxis));
}
else if (m_cmbAxisType->currentIndex() == ScaleDraw::Text)
{
m_cmbColName->setCurrentText(m_graph->axisFormatInfo(m_mappedaxis));
}
m_spnPrecision->setEnabled(format != 0);
if (m_mappedaxis == QwtPlot::xBottom || m_mappedaxis == QwtPlot::xTop)
{
m_spnAngle->setEnabled(labelsOn && axisOn);
m_spnAngle->setValue(m_graph->labelsRotation(m_mappedaxis));
}
else
{
m_spnAngle->setEnabled(false);
m_spnAngle->setValue(0);
}
m_cbtnAxisNumColor->setColor(m_graph->axisLabelsColor(m_mappedaxis));
QString formula = m_graph->axisFormula(m_mappedaxis);
m_txtFormula->setFixedWidth(150);
if (!formula.isEmpty())
{
m_chkShowFormula->setChecked(true);
m_txtFormula->setEnabled(true);
m_txtFormula->setText(formula);
}
else
{
m_chkShowFormula->setChecked(false);
m_txtFormula->setEnabled(false);
}
showAxis();
connect(m_chkShowFormula, SIGNAL(stateChanged(int)), this, SLOT(setModified()));
connect(m_chkShowAxis, SIGNAL(stateChanged(int)), this, SLOT(setModified()));
connect(m_cmbAxisType, SIGNAL(currentIndexChanged(int)), this, SLOT(setModified()));
connect(m_cmbAxisType, SIGNAL(editTextChanged(QString)), this, SLOT(setModified()));
connect(m_cmbMajorTicksType, SIGNAL(currentIndexChanged(int)), this, SLOT(setModified()));
//.........这里部分代码省略.........