本文整理汇总了C++中QwtPlot::plotLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlot::plotLayout方法的具体用法?C++ QwtPlot::plotLayout怎么用?C++ QwtPlot::plotLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlot
的用法示例。
在下文中一共展示了QwtPlot::plotLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arrangeLayers
QSize MultiLayer::arrangeLayers(bool userSize) {
const QRect rect = canvas->geometry();
gsl_vector *xTopR = gsl_vector_calloc(
graphs); // ratio between top axis + title and canvas height
gsl_vector *xBottomR =
gsl_vector_calloc(graphs); // ratio between bottom axis and canvas height
gsl_vector *yLeftR = gsl_vector_calloc(graphs);
gsl_vector *yRightR = gsl_vector_calloc(graphs);
gsl_vector *maxXTopHeight =
gsl_vector_calloc(rows); // maximum top axis + title height in a row
gsl_vector *maxXBottomHeight =
gsl_vector_calloc(rows); // maximum bottom axis height in a row
gsl_vector *maxYLeftWidth =
gsl_vector_calloc(cols); // maximum left axis width in a column
gsl_vector *maxYRightWidth =
gsl_vector_calloc(cols); // maximum right axis width in a column
gsl_vector *Y = gsl_vector_calloc(rows);
gsl_vector *X = gsl_vector_calloc(cols);
int i;
for (i = 0; i < graphs;
i++) { // calculate scales/canvas dimensions reports for each layer and
// stores them in the above vectors
Graph *gr = (Graph *)graphsList.at(i);
QwtPlot *plot = gr->plotWidget();
QwtPlotLayout *plotLayout = plot->plotLayout();
QRect cRect = plotLayout->canvasRect();
double ch = (double)cRect.height();
double cw = (double)cRect.width();
QRect tRect = plotLayout->titleRect();
QwtScaleWidget *scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::xTop);
int topHeight = 0;
if (!tRect.isNull()) topHeight += tRect.height() + plotLayout->spacing();
if (scale) {
QRect sRect = plotLayout->scaleRect(QwtPlot::xTop);
topHeight += sRect.height();
}
gsl_vector_set(xTopR, i, double(topHeight) / ch);
scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::xBottom);
if (scale) {
QRect sRect = plotLayout->scaleRect(QwtPlot::xBottom);
gsl_vector_set(xBottomR, i, double(sRect.height()) / ch);
}
scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::yLeft);
if (scale) {
QRect sRect = plotLayout->scaleRect(QwtPlot::yLeft);
gsl_vector_set(yLeftR, i, double(sRect.width()) / cw);
}
scale = (QwtScaleWidget *)plot->axisWidget(QwtPlot::yRight);
if (scale) {
QRect sRect = plotLayout->scaleRect(QwtPlot::yRight);
gsl_vector_set(yRightR, i, double(sRect.width()) / cw);
}
// calculate max scales/canvas dimensions ratio for each line and column and
// stores them to vectors
int row = i / cols;
if (row >= rows) row = rows - 1;
int col = i % cols;
double aux = gsl_vector_get(xTopR, i);
double old_max = gsl_vector_get(maxXTopHeight, row);
if (aux >= old_max) gsl_vector_set(maxXTopHeight, row, aux);
aux = gsl_vector_get(xBottomR, i);
if (aux >= gsl_vector_get(maxXBottomHeight, row))
gsl_vector_set(maxXBottomHeight, row, aux);
aux = gsl_vector_get(yLeftR, i);
if (aux >= gsl_vector_get(maxYLeftWidth, col))
gsl_vector_set(maxYLeftWidth, col, aux);
aux = gsl_vector_get(yRightR, i);
if (aux >= gsl_vector_get(maxYRightWidth, col))
gsl_vector_set(maxYRightWidth, col, aux);
}
double c_heights = 0.0;
for (i = 0; i < rows; i++) {
gsl_vector_set(Y, i, c_heights);
c_heights += 1 + gsl_vector_get(maxXTopHeight, i) +
gsl_vector_get(maxXBottomHeight, i);
}
double c_widths = 0.0;
for (i = 0; i < cols; i++) {
gsl_vector_set(X, i, c_widths);
c_widths += 1 + gsl_vector_get(maxYLeftWidth, i) +
gsl_vector_get(maxYRightWidth, i);
}
if (!userSize) {
l_canvas_width = int(
//.........这里部分代码省略.........
示例2: main
int main(int argc, char *argv[])
{
// QGuiApplication a(argc, argv);
QApplication a(argc, argv);
QwtPlot *plot = new QwtPlot();
QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setBorderRadius(10);
plot->setCanvas(canvas);
plot->setCanvasBackground(QColor("LIGHTGRAY"));
plot->enableAxis(QwtPlot::yRight);
plot->enableAxis(QwtPlot::xTop);
plot->setAxisTitle(QwtPlot::xBottom, "Xline");
plot->setAxisTitle(QwtPlot::xTop, "Xline");
plot->setAxisTitle(QwtPlot::yLeft, "Inline");
plot->setAxisTitle(QwtPlot::yRight, "Inline");
// float minx = srv->getStations().first().x();
// float maxx = srv->getStations().last().x();
plot->setAxisScale( QwtPlot::xBottom,3500,300);
// plot->setAxisScale( QwtPlot::xTop,minx,maxx );
// QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
// sd->setMinimumExtent( sd->extent( axisWidget( QwtPlot::yLeft )->font() ) );
plot->plotLayout()->setAlignCanvasToScales( true );
QFileDialog custDialog;
QStringList names = custDialog.getOpenFileNames(NULL, ("Open Files..."),QString(), ("UKOOA Files (*.p190 *.p90);;All Files (*)"));
// handle if the dialog was "Cancelled"
if(names.isEmpty())
{
return 0;
}
qSort(names.begin(), names.end());
QVector <QwtPlotCurve *> curves;
foreach (QString name, names)
{
QwtPlotCurve *vCurve = new QwtPlotCurve;
if(name.contains(QString( "NS1763")) || name.contains(QString("NS2029")))
{
QColor c = Qt::red;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::red,c , QSize( 2, 2 ) ) );
}
else
{
QColor c = Qt::green;
vCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, Qt::green,c , QSize( 2, 2 ) ) );
}
vCurve->setStyle( QwtPlotCurve::NoCurve );
vCurve->setPen( Qt::gray );
cout << name.toStdString() << endl;
QVector<QPointF> curveData;
// m_nameLineLable->setText(m_names.at(0));
QFile *ukFile = new QFile(QString(name));
bool rt = ukFile->open(QIODevice::ReadOnly);
cout << "return " << rt << endl;
qint64 icount = 0;
qint64 fileSize = ukFile->size();
char *data = new char[fileSize];
ukFile->read(data,fileSize);
QString sData = data;
QString shot = "SNS";
while (true)
{
ukFile->seek(icount);
ukFile->read(data,fileSize);
sData = data;;
if(icount>=fileSize)
{
break;
}
auto sPos = sData.indexOf(shot,0,Qt::CaseInsensitive);
QString cr = sData.mid(sPos,19);
if(cr.contains("\n"))
{
sPos +=2;
}
// auto shotNo = sData.mid(sPos+20,sPos+5);
QString shotNo = sData.mid(sPos+19,6);
int shotNos;
if(shotNo.contains("\n") || shotNo.contains("\r"))
{
shotNo = sData.mid(sPos+19,8);
int shift1 = shotNo.indexOf("\r");
int shift = shotNo.indexOf("\n");
// cout << shift1 << " " << shift << endl;
QString tmp = shotNo.mid(0,shift1);
tmp.append(shotNo.mid(shift+1,3));
shotNos = tmp.toInt();
}
else
//.........这里部分代码省略.........