All pastes #259866 Raw Edit

qt

public text v1 · immutable
#259866 ·published 2006-11-27 20:41 UTC
rendered paste body
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

// QT declares
#include <qmessagebox.h>
#include <qinputdialog.h>

// C++ declares
#include <iostream>
#include <fstream>
#include <string>

void Form1::plotProducer(int t) {
    
    long curve1;
    QString graph_name;
    QString graph_color;	    
    QStringList graph_colors;	    
    bool ok;
    
    // const int points = 10;    // kept for testing purposes
    const int points = QVariant(table1->numRows()).toInt();
    double x[points];
    double y[points];

    // set x,y axis to match the table attributes
    for (int j = 0; j<=points; j++) {
	x[j] = j + 1;
	y[j] = QVariant(table1->text(j,t)).toDouble();
    }
    
    // ask for color and graph name
    graph_name = QInputDialog::getText("Graph name", "Please choose a name for your graph...", QLineEdit::Normal, QString::null, &ok, this);
        
    graph_colors << "Blue" << "Red";
    graph_color = QInputDialog::getItem("Graph color", "Pick a color to draw the graph: ", graph_colors, 0, FALSE, &ok, this);
    
    
    /* shows a synos graph 
   for( int i=0; i<points; i++ )
    {
      x[i] = (3.0*3.14/double(points))*double(i);
    
      sn[i] = 2.0*sin( x[i] );
      sg[i] = (sn[i]>0)?1:((sn[i]<0)?-1:0);
    }        */

    qwtPlot1->setLegendPos( Qwt::Bottom );
    
    curve1 = qwtPlot1->insertCurve( graph_name, 100, 100);

    
    // copy the data into the curves
    qwtPlot1->setCurveData(curve1, x, y, points);
    qwtPlot1->setCurvePen(curve1, QPen( graph_color ) );
    
    // finally, refresh the plot
    qwtPlot1->replot();
    
}


void Form1::newEntry() {
    // let's find out the number of rows currently in the able
    int numRows = table1->numRows();
    // and now let's insert a new row after the last one
    table1->insertRows(numRows);
    // redraw the table to show the updated row-set.
    table1->show();  
}


void Form1::fileNew()
{

}


void Form1::fileOpen()
{

}


void Form1::fileSave()
{

}


void Form1::fileSaveAs()
{

}


void Form1::filePrint()
{

}


void Form1::fileExit()
{

}


void Form1::editUndo()
{

}


void Form1::editRedo()
{

}


void Form1::editCut()
{

}


void Form1::editCopy()
{

}


void Form1::editPaste()
{

}


void Form1::editFind()
{

}


void Form1::helpIndex()
{

}


void Form1::helpContents()
{

}


void Form1::helpAbout()
{

}

void Form1::plotProducerMP()
{
    plotProducer(1);
}