Example #1
0
ASKDemodulation::ASKDemodulation(float Time, float SamplingFrequency,
                                 const std::vector<int> &BitesVector)
    : ASKModulation(Time, SamplingFrequency, BitesVector) {
  modulatedSignal = getBuffer();

  generateDemodulation(BitesVector);
  drawChart((char *)"Chart_after_multiplication", multiBuffer);
  drawChart((char *)"Demodulated_signal", demodulatedSignal);
  drawChart((char *)"Binary_signal", binarySignal);
}
Example #2
0
FSKDemodulation::FSKDemodulation(float Time, float SamplingFrequency,
                                 const std::vector<int> &BitesVector)
    : FSKModulation(Time, SamplingFrequency, BitesVector) {
  modulatedSignal = getBuffer();

  generateDemodulation(BitesVector);
  drawChart((char *)"FSK_After_multiplication_no1", multiBuffer1);
  drawChart((char *)"FSK_After_multiplication_no2", multiBuffer2);
  drawChart((char *)"FSK_Demodulation", demodulatedSignal);
  drawChart((char *)"FSK_Binary_Signal", binarySignal);
}
RealtimeChart::RealtimeChart(const char* ytitle, const char* mainTitle,
	const char* labela, const char* labelb, QWidget *parent) 
	: QWidget(parent), m_yTitle(ytitle), m_mainTitle(mainTitle), m_labelA(labela), m_labelB(labelb)

{
    // Chart Viewer
    m_ChartViewer = new QChartViewer(this);
    m_ChartViewer->setGeometry(0, 0, 645, 270);
	m_ChartViewer->setFrameShape(QFrame::NoFrame);
    connect(m_ChartViewer, SIGNAL(viewPortChanged()), SLOT(drawChart()));

    // Clear data arrays to Chart::NoValue
    for (int i = 0; i < sampleSize; ++i)
        m_timeStamps[i] = m_dataSeriesA[i] = m_dataSeriesB[i] = m_dataSeriesC[i] = Chart::NoValue;

    // Set m_nextDataTime to the current time. It is used by the real time random number
    // generator so it knows what timestamp should be used for the next data point.
    m_nextDataTime = QDateTime::currentDateTime();

    // Set up the data acquisition mechanism. In this demo, we just use a timer to get a
    // sample every 250ms.
    QTimer *dataRateTimer = new QTimer(this);
    dataRateTimer->start(DataInterval);
    connect(dataRateTimer, SIGNAL(timeout()), SLOT(getData()));

    // Set up the chart update timer
    m_ChartUpdateTimer = new QTimer(this);
    connect(m_ChartUpdateTimer, SIGNAL(timeout()), SLOT(updateChart()));
	m_ChartUpdateTimer->start(1000);
}
Example #4
0
void SessionPositionsChart::paintEvent(QPaintEvent *)
{
    resetPaintRect();

    if (scaleRect.width() == 0 && scaleRect.height() == 0)
    {
        resetZoom();
    }

    QPainter p;
    p.begin(this);

    p.setBrush(QColor(20,20,20));
    p.setPen(QColor(20,20,20));
    p.drawRect(0, 0, width(), height());
    drawChart(&p);

    if (scaling)
        drawScaleRect(&p);

//    drawLegend(&p, 35, 5);

    p.end();

    if (lapDataArray.isEmpty())
        clearLapDataCoordinates(0);
}
Example #5
0
// method is called each time our chart needs to be repainted
void LineChart::paintEvent(QPaintEvent *) {
    // Repaint is only done if values has changed
    if (m_needs_repaint) {
        if (m_image != NULL)
            delete m_image;

        m_image = new QImage(size(), QImage::Format_ARGB32);

        QPainter image_painter(m_image); // create new empty (white) painter
        image_painter.begin(m_image);
        image_painter.fillRect(m_image->rect(), Qt::white);

        QFont smallFont("Helvetica", 8);
        image_painter.setFont(smallFont); // standard font settings

        // draw lines if data is available
        if (m_has_data) {
            drawChart(image_painter);
            drawLines(image_painter);
        }

        m_needs_repaint = false; // nearly all work done... ;-)
    }

    QPainter this_painter(this);
    this_painter.drawImage(QPoint(0, 0), *m_image);

    if (m_mouse_pressed) {
        QPen coord_pen(Qt::yellow, 1); // yellow, 1 pixel wide
        this_painter.setPen(coord_pen);
        this_painter.drawRect(m_mouse_x_min, m_mouse_y_min,
                (m_mouse_x_act - m_mouse_x_min),
                (m_mouse_y_act - m_mouse_y_min));
    }
}
Example #6
0
void WeatherChart::paintEvent(QPaintEvent *)
{
    resetPaintRect();

    QPainter p;
    p.begin(this);

    if (scaleRect.width() == 0 && scaleRect.height() == 0)
    {
        setMinMax();
        resetZoom();
    }

    p.setBrush(QColor(20,20,20));
    p.setPen(QColor(20,20,20));
    p.drawRect(0, 0, width(), height());

    drawAxes(&p);
    drawChart(&p);

    if (scaling)
        drawScaleRect(&p);

    p.end();
}
void BoltzmannInfoWidget::paintEvent(QPaintEvent *event) {
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QPen pen;
    pen.setColor(QColor(0xEE, 0xEE, 0xEE));
    pen.setWidth(3);
    painter.setPen(pen);
    painter.fillRect(event->rect(), QBrush(QColor(0x30, 0x30, 0x30)));
    drawCoords(&painter);
    drawLabels(&painter);
    drawChart(&painter);
    drawStatus(&painter);
}
Example #8
0
void SessionLapTimesChart::drawIntoImage(QImage &img)
{
    QPainter p;
    p.begin(&img);

    p.setBrush(QColor(20,20,20));
    p.setPen(QColor(20,20,20));
    p.drawRect(0, 0, width(), height());

    drawChart(&p);

    p.end();
}
Example #9
0
void WetDryChart::paintEvent(QPaintEvent *)
{
    resetPaintRect();
    setMinMax();

    QPainter p;
    p.begin(this);

    p.setBrush(QColor(20,20,20));
    p.setPen(QColor(20,20,20));
    p.drawRect(0, 0, width(), height());

    drawAxes(&p);
    drawChart(&p);

    p.end();
}
Example #10
0
/**
 * @brief WidgetCompLineChart::WidgetCompLineChart Construct a WidgetCompLineChart with given measures
 * @param parent parent object
 * @param meas first measure
 * @param meas2 second measure
 */
WidgetCompLineChart::WidgetCompLineChart(QWidget *parent, const Measure &meas, const Measure &meas2):QWidget(parent),ui(new Ui::WidgetCompLineChart),
    _meas(new Measure(meas)),_meas2(new Measure(meas2)),_mlist(new QStringList()), _ylist(new QStringList())
{
    ui->setupUi(this);
    this->setStyleSheet(
                "QPushButton#pushButtonSaveLineData {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonSaveLineData:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonSaveLineData:hover {"
                "background-color: rgb(130,130,180);}"

                "QPushButton#pushButtonRefresh {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonRefresh:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonRefresh:hover {"
                "background-color: rgb(130,130,180); }"
                );
    generateMunis();
    generateYears();
    ui->listLineChartMunicipality_4->setSelectionMode(QAbstractItemView::MultiSelection);
    ui->listLineChartYears_4->setSelectionMode(QAbstractItemView::MultiSelection);
    ui->listLineChartMunicipality_4->addItems(*_mlist);
    ui->listLineChartYears_4->addItems(*_ylist);
    drawChart();

}
Example #11
0
//
// Initialization
//
BOOL CFinancedemoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // *** code automatically generated by VC++ MFC AppWizard ***
    // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);         // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
    
    //
    // Intialialize the controls
    //
    initComboBox(m_TickerSymbol, tickerSymbols, 
        sizeof(tickerSymbols) / sizeof(*tickerSymbols), _T("Random Data 1"));
    initComboBox(m_TimeRange, timeRanges, 
        sizeof(timeRanges) / sizeof(*timeRanges), _T("6 months"));
    initComboBox(m_ChartSize, chartSizes, 
        sizeof(chartSizes) / sizeof(*chartSizes), _T("Large"));
    initComboBox(m_ChartType, chartTypes, 
        sizeof(chartTypes) / sizeof(*chartTypes), _T("CandleStick"));
    initComboBox(m_Band, bandTypes, 
        sizeof(bandTypes) / sizeof(*bandTypes), _T("Bollinger Band"));
    initComboBox(m_AvgType1, avgTypes, sizeof(avgTypes) / sizeof(*avgTypes), _T("Simple"));
    initComboBox(m_AvgType2, avgTypes, sizeof(avgTypes) / sizeof(*avgTypes), _T("Simple"));
    initComboBox(m_Indicator1, indicatorTypes, 
        sizeof(indicatorTypes) / sizeof(*indicatorTypes), _T("RSI"));
    initComboBox(m_Indicator2, indicatorTypes, 
        sizeof(indicatorTypes) / sizeof(*indicatorTypes), _T("MACD"));
    initComboBox(m_Indicator3, indicatorTypes, 
        sizeof(indicatorTypes) / sizeof(*indicatorTypes), _T("None"));
    initComboBox(m_Indicator4, indicatorTypes, 
        sizeof(indicatorTypes) / sizeof(*indicatorTypes), _T("None"));

    m_Volume.SetCheck(1);
    m_VGrid.SetCheck(1);
    m_HGrid.SetCheck(1);

    m_MovAvg1.SetWindowText(_T("5"));
    m_MovAvg2.SetWindowText(_T("20"));

    // Display the chart
    drawChart(&m_ChartViewer);
    return TRUE;
}
void PhysicalMemoryChart::paintEvent(QPaintEvent* /*event*/) {
	/* RAM usage: */
	/* don't rely on the SHARED_MEM value since it may refer to
	 * the size of the System V sharedmem in 2.4.x. Calculate instead! */

	t_memsize bufferMemory;
	
	bufferMemory = 0;
#if !defined(__svr4__) || !defined(sun)
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
	bufferMemory = ZERO_IF_NO_INFO(memoryInfos[BUFFER_MEM]);
#endif
#endif
	t_memsize cachedMemory = ZERO_IF_NO_INFO(memoryInfos[CACHED_MEM]);
	t_memsize freeMemory = ZERO_IF_NO_INFO(memoryInfos[FREE_MEM]);
	t_memsize totalMemory = ZERO_IF_NO_INFO(memoryInfos[TOTAL_MEM]) - bufferMemory - cachedMemory - freeMemory;
	
	QList<t_memsize> used;
	used.append(freeMemory);
	used.append(cachedMemory);
	used.append(bufferMemory);
	used.append(totalMemory);
	
	if (!colorsInitialized) {
		colorsInitialized = true;
		texts.append(i18n("Free Physical Memory"));
		colors.append(COLOR_FREE_MEMORY); // free 
		texts.append(i18n("Disk Cache"));
		colors.append(QColor(88, 176, 36)); // cached 
		texts.append(i18n("Disk Buffers"));
		colors.append(QColor(118, 237, 49)); // buffer
		texts.append(i18n("Application Data"));
		colors.append(COLOR_USED_MEMORY); // used+shared
	}
	
	drawChart(memoryInfos[TOTAL_MEM], used, colors, texts);

}
Example #13
0
/**
 * Construct a line chart widget of a given parent, active measure, low and high range
 * @param parent chosen parent
 * @param meas  active measure
 * @param range low/high range of the data
 */
widgetBarChart::widgetBarChart(QWidget *parent, const Measure &meas, const std::pair<double, double> &range):QWidget(parent),ui(new Ui::widgetBarChart),_meas(new Measure(meas))
{
    ui->setupUi(this);
    _range =range;
    this->setStyleSheet(
                "QPushButton#pushButtonSaveBarData {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonSaveBarData:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonSaveBarData:hover {"
                "background-color: rgb(130,130,180);}"

                "QPushButton#pushButtonRefresh {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButtonRefresh:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButtonRefresh:hover {"
                "background-color: rgb(130,130,180); }"
                );
    ui->listBarChartMunicipality->setSelectionMode(QAbstractItemView::MultiSelection);
    ui->listBarChartYears->setSelectionMode(QAbstractItemView::MultiSelection);
    //List Stuff
    ui->listBarChartMunicipality->addItems(_meas->stringMuniList());
    ui->listBarChartYears->addItems(_meas->yearRange());

    //Add title to bar chart
    ui->widgetBarChart_2->plotLayout()->insertRow(0);
    QString title = meas.name() + " Over the Years";
    ui->widgetBarChart_2->plotLayout()->addElement(0, 0, new QCPPlotTitle(ui->widgetBarChart_2, title));
    ui->widgetBarChart_2->yAxis->setLabel(_meas->name());


    //*********************set interractions*************************
    srand(QDateTime::currentDateTime().toTime_t());
      ui->widgetBarChart_2->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
                                      QCP::iSelectLegend | QCP::iSelectPlottables);

      ui->widgetBarChart_2->axisRect()->setupFullAxesBox();
      ui->widgetBarChart_2->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items

      // connect slot that ties some axis selections together (especially opposite axes):
      connect(ui->widgetBarChart_2, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
      // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
      connect(ui->widgetBarChart_2, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
      connect(ui->widgetBarChart_2, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

      // make bottom and left axes transfer their ranges to top and right axes:
      connect(ui->widgetBarChart_2->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->widgetBarChart_2->xAxis2, SLOT(setRange(QCPRange)));
      connect(ui->widgetBarChart_2->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->widgetBarChart_2->yAxis2, SLOT(setRange(QCPRange)));

      // connect some interaction slots:
      connect(ui->widgetBarChart_2, SIGNAL(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*,QCPPlotTitle*)));
      connect(ui->widgetBarChart_2, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
      connect(ui->widgetBarChart_2, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));

      // setup policy and connect slot for context menu popup:
      ui->widgetBarChart_2->setContextMenuPolicy(Qt::CustomContextMenu);
      connect(ui->widgetBarChart_2, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint)));


    drawChart();

}
Example #14
0
/**
 * @brief WidgetCompLineChart::on_listLineChartYears_4_itemSelectionChanged reload the graph
 */
void WidgetCompLineChart::on_listLineChartYears_4_itemSelectionChanged()
{
    drawChart();
}
Example #15
0
/**
 * @brief WidgetCompLineChart::on_pushButtonRefresh_clicked reload the chart
 */
void WidgetCompLineChart::on_pushButtonRefresh_clicked()
{
    drawChart();
}
Example #16
0
/**
 * @brief WidgetCompLineChart::on_listLineChartMunicipality_4_itemSelectionChanged reload the chart
 */
void WidgetCompLineChart::on_listLineChartMunicipality_4_itemSelectionChanged()
{
    drawChart();
}
Example #17
0
//
// User selection has changed - update the chart
//
void CFinancedemoDlg::OnSelectChange() 
{
    drawChart(&m_ChartViewer);  
}
Example #18
0
void MaterialEditDialog::createControls()
{    
    lstProperties = new QListWidget(this);
    lstProperties->setMouseTracking(true);
    lstProperties->setMaximumWidth(200);

    connect(lstProperties, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(doPropertyChanged(QListWidgetItem *, QListWidgetItem *)));

    txtName = new QLineEdit();
    txtDescription = new QLineEdit();

    QGridLayout *layoutNameAndDescription = new QGridLayout();
    layoutNameAndDescription->addWidget(new QLabel(tr("Name:")), 0, 0);
    layoutNameAndDescription->addWidget(txtName, 0, 1);
    layoutNameAndDescription->addWidget(new QLabel(tr("Description:")), 1, 0);
    layoutNameAndDescription->addWidget(txtDescription, 2, 0, 1, 3);

    QPushButton *btnAddProperty = new QPushButton(tr("Add..."));
    btnAddProperty->setDefault(false);

    QAction *actAddCustom = new QAction(tr("Custom property"), this);
    connect(actAddCustom, SIGNAL(triggered()), this, SLOT(addProperty()));

    // TODO: more general
    QAction *actAddThermalConductivity = new QAction(tr("Thermal conductivity"), this);
    connect(actAddThermalConductivity, SIGNAL(triggered()), this, SLOT(addPropertyThermalConductivity()));
    QAction *actAddSpecificHeat = new QAction(tr("Specific heat"), this);
    connect(actAddSpecificHeat, SIGNAL(triggered()), this, SLOT(addPropertySpecificHeat()));
    QAction *actAddDensity = new QAction(tr("Density"), this);
    connect(actAddDensity, SIGNAL(triggered()), this, SLOT(addPropertyDensity()));
    QAction *actAddMagneticPermeability = new QAction(tr("Magnetic permeability"), this);
    connect(actAddMagneticPermeability, SIGNAL(triggered()), this, SLOT(addPropertyMagneticPermeability()));

    QMenu *menu = new QMenu();
    menu->addAction(actAddCustom);
    menu->addSeparator();
    menu->addAction(actAddThermalConductivity);
    menu->addAction(actAddSpecificHeat);
    menu->addAction(actAddDensity);
    menu->addSeparator();
    menu->addAction(actAddMagneticPermeability);

    btnAddProperty->setMenu(menu);

    btnDeleteProperty = new QPushButton(tr("Delete"));
    btnDeleteProperty->setDefault(false);
    connect(btnDeleteProperty, SIGNAL(clicked()), this, SLOT(deleteProperty()));

    QGridLayout *layoutList = new QGridLayout();
    layoutList->addWidget(lstProperties, 0, 0, 1, 2);
    layoutList->addWidget(btnAddProperty, 1, 0);
    layoutList->addWidget(btnDeleteProperty, 1, 1);

    propertyGUI = createPropertyGUI();

    QHBoxLayout *layoutNonlinearProperties = new QHBoxLayout();
    layoutNonlinearProperties->addLayout(layoutList);
    layoutNonlinearProperties->addWidget(propertyGUI, 1);

    // table
    txtPropertyTableKeys = new QPlainTextEdit();
    txtPropertyTableValues = new QPlainTextEdit();

    QGridLayout *layoutTable = new QGridLayout();
    layoutTable->addWidget(new QLabel(tr("Keys:")), 0, 0);
    layoutTable->addWidget(txtPropertyTableKeys, 1, 0);
    layoutTable->addWidget(new QLabel(tr("Values:")), 0, 1);
    layoutTable->addWidget(txtPropertyTableValues, 1, 1);

    widNonlinearTable = new QGroupBox(tr("Table"));
    widNonlinearTable->setLayout(layoutTable);

    // function
    txtPropertyFunction = new ScriptEditor(currentPythonEngine(), this);
    txtPropertyFunctionFrom = new LineEditDouble(0.0);
    txtPropertyFunctionTo = new LineEditDouble(0.0);

    QGridLayout *layoutFunction = new QGridLayout();
    layoutFunction->addWidget(txtPropertyFunction, 0, 0, 1, 4);
    layoutFunction->addWidget(new QLabel(tr("From:")), 1, 0);
    layoutFunction->addWidget(txtPropertyFunctionFrom, 1, 1);
    layoutFunction->addWidget(new QLabel(tr("To:")), 1, 2);
    layoutFunction->addWidget(txtPropertyFunctionTo, 1, 3);
    layoutFunction->setRowStretch(0, 1);

    widNonlinearFunction = new QGroupBox(tr("Nonlinear function"));
    widNonlinearFunction->setLayout(layoutFunction);

    chartNonlinear = new QCustomPlot();
    chartNonlinear->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
    chartNonlinear->setMinimumHeight(120);
    chartNonlinear->addGraph();
    chartNonlinear->graph(0)->setLineStyle(QCPGraph::lsLine);

    QHBoxLayout *layoutChartNonlinear = new QHBoxLayout();
    layoutChartNonlinear->addWidget(chartNonlinear);

    widChartNonlinear = new QGroupBox(tr("Chart"));
    widChartNonlinear->setLayout(layoutChartNonlinear);

    layoutNonlinearType = new QStackedLayout();
    layoutNonlinearType->addWidget(widNonlinearFunction);
    layoutNonlinearType->addWidget(widNonlinearTable);

    QHBoxLayout *layoutNonlinearChart = new QHBoxLayout();
    layoutNonlinearChart->addLayout(layoutNonlinearType, 2);
    layoutNonlinearChart->addWidget(widChartNonlinear, 1);

    QVBoxLayout *layoutNonlinear = new QVBoxLayout();
    layoutNonlinear->addLayout(layoutNonlinearProperties);
    layoutNonlinear->addLayout(layoutNonlinearChart, 1);

    // dialog buttons
    QPushButton *btnPlot = new QPushButton(tr("Plot"));
    connect(btnPlot, SIGNAL(clicked()), this, SLOT(drawChart()));

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    buttonBox->addButton(btnPlot, QDialogButtonBox::ActionRole);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addLayout(layoutNameAndDescription);
    layout->addLayout(layoutNonlinear, 1);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);
}