crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

> кто-то работал с qcustomplot ?
_Vitaliy_
  опции профиля:
сообщение 27.8.2014, 19:05
Сообщение #1


Студент
*

Группа: Участник
Сообщений: 59
Регистрация: 20.11.2008
Пользователь №: 428

Спасибо сказали: 3 раз(а)




Репутация:   0  


Если да, то откликнитесь, есть несколько вопросов...
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение
 
Начать новую тему
Ответов
Steklova Olga
  опции профиля:
сообщение 29.8.2014, 17:34
Сообщение #2


Участник
**

Группа: Участник
Сообщений: 198
Регистрация: 27.9.2011
Из: Санкт-Петербург
Пользователь №: 2912

Спасибо сказали: 5 раз(а)




Репутация:   4  


graphics()
void MainWindow::graphics()
{
    ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
    ui->customPlot->axisRect()->setRangeDrag(Qt::Vertical);
    ui->customPlot->axisRect()->setRangeZoom(Qt::Vertical);

    ui->customPlot->addGraph(ui->customPlot->xAxis, ui->customPlot->yAxis);
    ui->customPlot->addGraph(ui->customPlot->xAxis, ui->customPlot->yAxis);
    ui->customPlot->addGraph(ui->customPlot->xAxis, ui->customPlot->yAxis);

    ui->customPlot->graph(0)->setLineStyle(QCPGraph::lsLine);
    ui->customPlot->graph(1)->setLineStyle(QCPGraph::lsLine);
    ui->customPlot->graph(2)->setLineStyle(QCPGraph::lsLine);

    ui->customPlot->graph(0)->setPen(QPen(Qt::red, 5));
    ui->customPlot->graph(1)->setPen(QPen(Qt::yellow, 5));
    ui->customPlot->graph(2)->setPen(QPen(Qt::green, 5));

    ui->customPlot->xAxis->setVisible(true);
    ui->customPlot->yAxis->setVisible(true);
    ui->customPlot->xAxis2->setVisible(true);
    ui->customPlot->yAxis2->setVisible(true);

    ui->customPlot->xAxis->setBasePen(QPen(Qt::black));
    ui->customPlot->yAxis->setBasePen(QPen(Qt::black));
    ui->customPlot->xAxis2->setBasePen(QPen(Qt::black));
    ui->customPlot->yAxis2->setBasePen(QPen(Qt::black));

    QVector<double> x(250), y1(250), y2(250), y3(250);
    for (int i=0; i<250; ++i)
    {
        x[i] = i;
        y1[i] = sin(x[i]/10);
        y2[i] = sin(x[i]/10) + 1.0;
        y3[i] = cos(x[i]/10) + 2.0;
    }

    connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    ui->customPlot->graph(0)->setData(x, y1);
    ui->customPlot->graph(1)->setData(x, y2);
    ui->customPlot->graph(2)->setData(x, y3);

    ui->customPlot->rescaleAxes();

    ui->customPlot->replot();
}
on_btn_green_check_clicked()
void MainWindow::on_btn_green_check_clicked()
{
    disconnect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    disconnect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    //все графики кроме зеленого переключаем на 2-ю неподвижную оцифровку
    ui->customPlot->graph(0)->setKeyAxis(ui->customPlot->xAxis2);
    ui->customPlot->graph(0)->setValueAxis(ui->customPlot->yAxis2);
    ui->customPlot->graph(1)->setKeyAxis(ui->customPlot->xAxis2);
    ui->customPlot->graph(1)->setValueAxis(ui->customPlot->yAxis2);

    ui->customPlot->xAxis->setBasePen(QPen(Qt::green, 2));
    ui->customPlot->yAxis->setBasePen(QPen(Qt::green, 2));

    ui->customPlot->replot();
}
on_btn_green_uncheck_clicked()
void MainWindow::on_btn_green_uncheck_clicked()
{
    ui->customPlot->yAxis->setRange(ui->customPlot->yAxis2->range()); //можно это не делать (или делать, если нужно)

    connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    //все графики кроме зеленого возвращаем на 1-ю подвижную оцифровку
    ui->customPlot->graph(0)->setKeyAxis(ui->customPlot->xAxis);
    ui->customPlot->graph(0)->setValueAxis(ui->customPlot->yAxis);
    ui->customPlot->graph(1)->setKeyAxis(ui->customPlot->xAxis);
    ui->customPlot->graph(1)->setValueAxis(ui->customPlot->yAxis);

    ui->customPlot->xAxis->setBasePen(QPen(Qt::black));
    ui->customPlot->yAxis->setBasePen(QPen(Qt::black));

    ui->customPlot->replot();
}

Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Сообщений в этой теме
- _Vitaliy_   кто-то работал с qcustomplot ?   27.8.2014, 19:05
- - Steklova Olga   Да, приходилось немного...   28.8.2014, 9:23
|- - _Vitaliy_   Цитата(Steklova Olga @ 28.8.2014, 8:23) Д...   28.8.2014, 11:13
- - Steklova Olga   При перемещении произвольного графика по оси OY зн...   28.8.2014, 20:08
- - _Vitaliy_   Начинаем с простого... Необходимо реализовать: 1. ...   28.8.2014, 20:31
- - Steklova Olga   А как ты рисуешь несколько графиков на одном custo...   29.8.2014, 11:04
- - _Vitaliy_   Рисую стандартно: ui->customPlot->addGrap...   29.8.2014, 11:45
- - Steklova Olga   Цитата(_Vitaliy_ @ 28.8.2014, 20:31) Цита...   29.8.2014, 12:16
- - Steklova Olga   Цитата(_Vitaliy_ @ 29.8.2014, 11:45) Полу...   29.8.2014, 13:15
- - _Vitaliy_   ЦитатаА прокручивается сама область customPlot...   29.8.2014, 13:39
- - Steklova Olga   ты не ответил на сообщение #8   29.8.2014, 14:06
- - Steklova Olga   graphics()void MainWindow::graphics(...   29.8.2014, 17:34
- - Steklova Olga   а для оцифровки on_btn_green_check_clicked()void M...   29.8.2014, 18:05
- - _Vitaliy_   Отвечаю на 8 пост. ЦитатаЕсли ты переместишь синий...   29.8.2014, 20:14
- - _Vitaliy_   Доброго времени суток. Посмотрел Ваши решения, нем...   30.8.2014, 8:23
- - Steklova Olga   Насчет моего кода... Кинь на свое окно рядом с ком...   1.9.2014, 11:12
- - _Vitaliy_   пока не "победил" адекватное масштабиров...   1.9.2014, 13:08
- - Steklova Olga   я смотрела "твой" проект - искуроченный ...   1.9.2014, 14:15
- - _Vitaliy_   спасибо, честно говоря 17 сообщение я написал не в...   1.9.2014, 14:52
- - skyer_   Приветствую, нужен совет как нарисовать горизонтал...   14.10.2014, 21:27
- - Steklova Olga   Цитата(skyer_ @ 14.10.2014, 21:27) Привет...   30.10.2014, 20:13
- - skyer_   Цитата(Steklova Olga @ 30.10.2014, 20:13)...   1.11.2014, 23:59


Быстрый ответОтветить в данную темуНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0




RSS Текстовая версия Сейчас: 28.4.2024, 5:48